Index: admin/js/_plugins.js
===================================================================
--- admin/js/_plugins.js	(revision 3706)
+++ admin/js/_plugins.js	(revision 3762)
@@ -5,5 +5,5 @@
   // expand a module line
   $('table.modules.expandable tr.line').each(function() {
-    $('td.module-name', this).toggleWithLegend($(this).next('.module-more'), {
+    $('td.module-name, th.module-name', this).toggleWithLegend($(this).next('.module-more'), {
       img_on_src: dotclear.img_plus_src,
       img_on_alt: dotclear.img_plus_alt,
Index: admin/media_item.php
===================================================================
--- admin/media_item.php	(revision 3761)
+++ admin/media_item.php	(revision 3731)
@@ -639,9 +639,9 @@
     $params = array(
         'post_type' => '',
-        'join'      => 'LEFT OUTER JOIN ' . $core->prefix . 'post_media PM ON P.post_id = PM.post_id ',
+        'from'      => 'LEFT OUTER JOIN ' . $core->prefix . 'post_media PM ON P.post_id = PM.post_id ',
         'sql'       => 'AND (' .
-                            'PM.media_id = ' . (integer) $id . ' ' .
-                            "OR post_content_xhtml LIKE '%" . $core->con->escape($file->relname) . "%' " .
-                            "OR post_excerpt_xhtml LIKE '%" . $core->con->escape($file->relname) . "%' "
+        'PM.media_id = ' . (integer) $id . ' ' .
+        "OR post_content_xhtml LIKE '%" . $core->con->escape($file->relname) . "%' " .
+        "OR post_excerpt_xhtml LIKE '%" . $core->con->escape($file->relname) . "%' "
     );
 
Index: admin/style/default.css
===================================================================
--- admin/style/default.css	(revision 3731)
+++ admin/style/default.css	(revision 3762)
@@ -885,5 +885,5 @@
   margin-bottom: .5em; }
 
-th {
+th:not(.module-name) {
   border-width: 1px 0 1px 0;
   border-style: solid;
@@ -894,5 +894,6 @@
   text-align: left; }
 
-td {
+td, th.module-name {
+  font-weight: normal;
   border-width: 0 0 1px 0;
   border-style: solid;
Index: admin/style/scss/partials/_markup.scss
===================================================================
--- admin/style/scss/partials/_markup.scss	(revision 3517)
+++ admin/style/scss/partials/_markup.scss	(revision 3762)
@@ -105,5 +105,5 @@
 }
 
-th {
+th:not(.module-name) {
 	border-width: 1px 0 1px 0;
 	border-style: solid;
@@ -115,5 +115,6 @@
 }
 
-td {
+td, th.module-name {
+  font-weight: normal;
 	border-width: 0 0 1px 0;
 	border-style: solid;
Index: inc/admin/lib.moduleslist.php
===================================================================
--- inc/admin/lib.moduleslist.php	(revision 3731)
+++ inc/admin/lib.moduleslist.php	(revision 3762)
@@ -625,5 +625,5 @@
             $tds++;
             echo
-                '<td class="module-name nowrap" scope="row">';
+                '<th class="module-name nowrap" scope="row">';
             if (in_array('checkbox', $cols)) {
                 if (in_array('expander', $cols)) {
Index: inc/core/class.dc.auth.php
===================================================================
--- inc/core/class.dc.auth.php	(revision 3761)
+++ inc/core/class.dc.auth.php	(revision 3731)
@@ -93,14 +93,13 @@
     {
         # Check user and password
-        $sql = new dcSelectStatement($this->core, 'coreAuthCheckUser');
-        $sql
-            ->columns(array('user_id', 'user_super', 'user_pwd', 'user_change_pwd', 'user_name', 'user_firstname',
-                'user_displayname', 'user_email', 'user_url', 'user_default_blog', 'user_options', 'user_lang',
-                'user_tz', 'user_post_status', 'user_creadt', 'user_upddt'))
-            ->from($this->user_table)
-            ->where('user_id = ' . $sql->quote($user_id));
+        $strReq = 'SELECT user_id, user_super, user_pwd, user_change_pwd, ' .
+        'user_name, user_firstname, user_displayname, user_email, ' .
+        'user_url, user_default_blog, user_options, ' .
+        'user_lang, user_tz, user_post_status, user_creadt, user_upddt ' .
+        'FROM ' . $this->con->escapeSystem($this->user_table) . ' ' .
+        "WHERE user_id = '" . $this->con->escape($user_id) . "' ";
 
         try {
-            $rs = $this->con->select($sql->statement());
+            $rs = $this->con->select($strReq);
         } catch (Exception $e) {
             $err = $e->getMessage();
@@ -147,8 +146,5 @@
                 $cur           = $this->con->openCursor($this->user_table);
                 $cur->user_pwd = (string) $rs->user_pwd;
-
-                $sql = new dcUpdateStatement($this->core, 'coreAuthCheckUser');
-                $sql->where('user_id = ' . $sql->quote($rs->user_id));
-                $cur->update($sql->whereStatement());
+                $cur->update("WHERE user_id = '" . $rs->user_id . "'");
             }
         } elseif ($user_key != '') {
@@ -622,9 +618,7 @@
     public function recoverUserPassword($recover_key)
     {
-        $sql = new dcSelectStatement($this->core, 'coreAuthRecoverUserPwd');
-        $sql
-            ->columns(array('user_id', 'user_email'))
-            ->from($this->user_table)
-            ->where('user_recover_key = ' . $sql->quote($recover_key));
+        $strReq = 'SELECT user_id, user_email ' .
+        'FROM ' . $this->user_table . ' ' .
+        "WHERE user_recover_key = '" . $this->con->escape($recover_key) . "' ";
 
         $rs = $this->con->select($strReq);
@@ -641,7 +635,5 @@
         $cur->user_change_pwd  = 1; // User will have to change this temporary password at next login
 
-        $sql = new dcUpdateStatement($this->core, 'coreAuthRecoverUserPwd');
-        $sql->where('user_recover_key = ' . $sql->quote($recover_key));
-        $cur->update($sql->whereStatement());
+        $cur->update("WHERE user_recover_key = '" . $this->con->escape($recover_key) . "'");
 
         return array('user_email' => $rs->user_email, 'user_id' => $rs->user_id, 'new_pass' => $new_pass);
Index: inc/core/class.dc.blog.php
===================================================================
--- inc/core/class.dc.blog.php	(revision 3761)
+++ inc/core/class.dc.blog.php	(revision 3731)
@@ -209,9 +209,5 @@
         $cur->blog_upddt = date('Y-m-d H:i:s');
 
-        $sql = new dcUpdateStatement($this->core, 'coreTriggerBlog');
-        $sql
-            ->where('blog_id = ' . $sql->quote($this->id));
-
-        $cur->update($sql->whereStatement());
+        $cur->update("WHERE blog_id = '" . $this->con->escape($this->id) . "' ");
 
         # --BEHAVIOR-- coreBlogAfterTriggerBlog
@@ -245,12 +241,11 @@
         # Get posts affected by comments edition
         if (empty($affected_posts)) {
-            $sql = new dcSelectStatement($this->core, 'coreTriggerCommentsScope');
-            $sql
-                ->columns('post_id')
-                ->from($this->prefix . 'comment')
-                ->where('comment_id' . $sql->in($comments_ids))
-                ->group('post_id');
-
-            $rs = $this->con->select($sql->statement());
+            $strReq =
+            'SELECT post_id ' .
+            'FROM ' . $this->prefix . 'comment ' .
+            'WHERE comment_id' . $this->con->in($comments_ids) .
+                'GROUP BY post_id';
+
+            $rs = $this->con->select($strReq);
 
             $affected_posts = array();
@@ -258,5 +253,4 @@
                 $affected_posts[] = (integer) $rs->post_id;
             }
-            unset($sql);
         }
 
@@ -266,15 +260,12 @@
 
         # Count number of comments if exists for affected posts
-        $sql = new dcSelectStatement($this->core, 'coreTriggerCommentsCount');
-        $sql
-            ->columns(array('post_id', 'COUNT(post_id) AS nb_comment', 'comment_trackback'))
-            ->from($this->prefix . 'comment')
-            ->where(array(
-                'comment_status = 1',
-                'post_id' . $sql->in($affected_posts)
-            ))
-            ->group(array('post_id', 'comment_trackback'));
-
-        $rs = $this->con->select($sql->statement());
+        $strReq =
+        'SELECT post_id, COUNT(post_id) AS nb_comment, comment_trackback ' .
+        'FROM ' . $this->prefix . 'comment ' .
+        'WHERE comment_status = 1 ' .
+        'AND post_id' . $this->con->in($affected_posts) .
+            'GROUP BY post_id,comment_trackback';
+
+        $rs = $this->con->select($strReq);
 
         $posts = array();
@@ -470,23 +461,21 @@
     private function getCategoriesCounter($params = array())
     {
-        $sql = new dcSelectStatement($this->core, 'coreGetCategoriesCounter');
-        $sql
-            ->columns(array('C.cat_id', 'COUNT(P.post_id) AS nb_post'))
-            ->from($this->prefix . 'category AS C')
-            ->join('JOIN ' . $this->prefix . 'post P ' .
-                'ON (C.cat_id = P.cat_id AND P.blog_id = ' . $sql->quote($this->id) . ')')
-            ->where('C.blog_id = ' . $sql->quote($this->id));
+        $strReq =
+        'SELECT  C.cat_id, COUNT(P.post_id) AS nb_post ' .
+        'FROM ' . $this->prefix . 'category AS C ' .
+        'JOIN ' . $this->prefix . "post P ON (C.cat_id = P.cat_id AND P.blog_id = '" . $this->con->escape($this->id) . "' ) " .
+        "WHERE C.blog_id = '" . $this->con->escape($this->id) . "' ";
 
         if (!$this->core->auth->userID()) {
-            $sql->where('P.post_status = 1');
+            $strReq .= 'AND P.post_status = 1 ';
         }
 
         if (!empty($params['post_type'])) {
-            $sql->where('P.post_type ' . $sql->in($params['post_type']));
-        }
-
-        $sql->group('C.cat_id');
-
-        $rs       = $this->con->select($sql->statement());
+            $strReq .= 'AND P.post_type ' . $this->con->in($params['post_type']);
+        }
+
+        $strReq .= 'GROUP BY C.cat_id ';
+
+        $rs       = $this->con->select($strReq);
         $counters = array();
         while ($rs->fetch()) {
@@ -579,11 +568,7 @@
         $this->core->callBehavior('coreBeforeCategoryUpdate', $this, $cur);
 
-        $sql = new dcUpdateStatement($this->core, 'coreCategoryUpdate');
-        $sql
-            ->where(array(
-                'cat_id = ' . (integer) $id,
-                'blog_id = ' . $sql->quote($this->id)
-            ));
-        $cur->update($sql->whereStatement());
+        $cur->update(
+            'WHERE cat_id = ' . (integer) $id . ' ' .
+            "AND blog_id = '" . $this->con->escape($this->id) . "' ");
 
         # --BEHAVIOR-- coreAfterCategoryUpdate
@@ -654,13 +639,10 @@
         }
 
-        $sql = new dcSelectStatement($this->core, 'coreCategoryPostCount');
-        $sql
-            ->columns('COUNT(post_id) AS nb_post')
-            ->from($this->prefix . 'post')
-            ->where(array(
-                'cat_id = ' . (integer) $id,
-                'blog_id = ' . $sql->quote($this->id)
-            ));
-        $rs = $this->con->select($sql->statement());
+        $strReq = 'SELECT COUNT(post_id) AS nb_post ' .
+        'FROM ' . $this->prefix . 'post ' .
+        'WHERE cat_id = ' . (integer) $id . ' ' .
+        "AND blog_id = '" . $this->con->escape($this->id) . "' ";
+
+        $rs = $this->con->select($strReq);
 
         if ($rs->nb_post > 0) {
@@ -687,23 +669,30 @@
     private function checkCategory($title, $url, $id = null)
     {
-        // Let's check if URL is taken...
-        $sql = new dcSelectStatement($this->core, 'coreCheckCategoryURL');
-        $sql
-            ->columns('cat_url')
-            ->from($this->prefix . 'category')
-            ->where('blog_id = ' . $sql->quote($this->id))
-            ->order('cat_url DESC');
-        if ($id) {
-            $sql->where('AND cat_id <> ' . (integer) $i);
-        }
-        $sql->cond('AND cat_url = ' . $sql->quote($url));
-
-        $rs = $this->con->select($sql->statement());
+        # Let's check if URL is taken...
+        $strReq =
+        'SELECT cat_url FROM ' . $this->prefix . 'category ' .
+        "WHERE cat_url = '" . $this->con->escape($url) . "' " .
+        ($id ? 'AND cat_id <> ' . (integer) $id . ' ' : '') .
+        "AND blog_id = '" . $this->con->escape($this->id) . "' " .
+            'ORDER BY cat_url DESC';
+
+        $rs = $this->con->select($strReq);
 
         if (!$rs->isEmpty()) {
-            // Replace condition on cat_url
-            $sql->cond('AND cat_url ' . $sql->regexp($url), true);
-
-            $rs = $this->con->select($sql->statement());
+            if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') {
+                $clause = "REGEXP '^" . $this->con->escape($url) . "[0-9]+$'";
+            } elseif ($this->con->driver() == 'pgsql') {
+                $clause = "~ '^" . $this->con->escape($url) . "[0-9]+$'";
+            } else {
+                $clause = "LIKE '" . $this->con->escape($url) . "%'";
+            }
+            $strReq =
+            'SELECT cat_url FROM ' . $this->prefix . 'category ' .
+            "WHERE cat_url " . $clause . ' ' .
+            ($id ? 'AND cat_id <> ' . (integer) $id . ' ' : '') .
+            "AND blog_id = '" . $this->con->escape($this->id) . "' " .
+                'ORDER BY cat_url DESC ';
+
+            $rs = $this->con->select($strReq);
             $a  = array();
             while ($rs->fetch()) {
@@ -802,51 +791,58 @@
         $this->core->callBehavior('coreBlogBeforeGetPosts', $params);
 
-        $sql = new dcSelectStatement($this->core, 'coreGetPosts');
-
         if ($count_only) {
-            $sql->columns('count(DISTINCT P.post_id)');
+            $strReq = 'SELECT count(DISTINCT P.post_id) ';
         } elseif (!empty($params['sql_only'])) {
-            $sql->columns('P.post_id');
+            $strReq = 'SELECT P.post_id ';
         } else {
-            if (empty($params['no_content'])) {
-                $sql->columns(array('post_excerpt', 'post_excerpt_xhtml', 'post_content', 'post_content_xhtml', 'post_notes'));
+            if (!empty($params['no_content'])) {
+                $content_req = '';
+            } else {
+                $content_req =
+                    'post_excerpt, post_excerpt_xhtml, ' .
+                    'post_content, post_content_xhtml, post_notes, ';
             }
 
             if (!empty($params['columns']) && is_array($params['columns'])) {
-                $sql->columns($params['columns']);
-            }
-
-            $sql->columns(array('P.post_id', 'P.blog_id', 'P.user_id', 'P.cat_id', 'post_dt', 'post_tz', 'post_creadt',
-                'post_upddt', 'post_format', 'post_password', 'post_url', 'post_lang', 'post_title', 'post_type',
-                'post_meta', 'post_status', 'post_firstpub', 'post_selected', 'post_position', 'post_open_comment',
-                'post_open_tb', 'nb_comment', 'nb_trackback', 'U.user_name', 'U.user_firstname', 'U.user_displayname',
-                'U.user_email', 'U.user_url', 'C.cat_title', 'C.cat_url', 'C.cat_desc'));
-        }
-
-        $sql->from($this->prefix . 'post P')
-            ->join('INNER JOIN ' . $this->prefix . 'user U ON U.user_id = P.user_id')
-            ->join('LEFT OUTER JOIN ' . $this->prefix . 'category C ON P.cat_id = C.cat_id');
-
-        if (!empty($params['join'])) {
-            $sql->join($params['join']);
-        }
+                $content_req .= implode(', ', $params['columns']) . ', ';
+            }
+
+            $strReq =
+                'SELECT P.post_id, P.blog_id, P.user_id, P.cat_id, post_dt, ' .
+                'post_tz, post_creadt, post_upddt, post_format, post_password, ' .
+                'post_url, post_lang, post_title, ' . $content_req .
+                'post_type, post_meta, ' .
+                'post_status, post_firstpub, post_selected, post_position, ' .
+                'post_open_comment, post_open_tb, nb_comment, nb_trackback, ' .
+                'U.user_name, U.user_firstname, U.user_displayname, U.user_email, ' .
+                'U.user_url, ' .
+                'C.cat_title, C.cat_url, C.cat_desc ';
+        }
+
+        $strReq .=
+        'FROM ' . $this->prefix . 'post P ' .
+        'INNER JOIN ' . $this->prefix . 'user U ON U.user_id = P.user_id ' .
+        'LEFT OUTER JOIN ' . $this->prefix . 'category C ON P.cat_id = C.cat_id ';
 
         if (!empty($params['from'])) {
-            $sql->from($params['from']);
-        }
-
-        $sql->where('P.blog_id = ' . $sql->quote($this->id));
+            $strReq .= $params['from'] . ' ';
+        }
+
+        $strReq .=
+        "WHERE P.blog_id = '" . $this->con->escape($this->id) . "' ";
 
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $cond = '((post_status = 1';
+            $strReq .= 'AND ((post_status = 1 ';
+
             if ($this->without_password) {
-                $cond .= ' AND post_password IS NULL';
-            }
-            $cond .= ')';
+                $strReq .= 'AND post_password IS NULL ';
+            }
+            $strReq .= ') ';
+
             if ($this->core->auth->userID()) {
-                $cond .= 'OR P.user_id = ' . $sql->quote($this->core->auth->userID());
-            }
-            $cond .= ')';
-            $sql->where($cond);
+                $strReq .= "OR P.user_id = '" . $this->con->escape($this->core->auth->userID()) . "')";
+            } else {
+                $strReq .= ') ';
+            }
         }
 
@@ -854,8 +850,8 @@
         if (isset($params['post_type'])) {
             if (is_array($params['post_type']) || $params['post_type'] != '') {
-                $sql->where('post_type ' . $sql->in($params['post_type']));
+                $strReq .= 'AND post_type ' . $this->con->in($params['post_type']);
             }
         } else {
-            $sql->where("post_type = 'post' ");
+            $strReq .= "AND post_type = 'post' ";
         }
 
@@ -866,5 +862,5 @@
                 $params['post_id'] = array((integer) $params['post_id']);
             }
-            $sql->where('P.post_id ' . $sql->in($params['post_id']));
+            $strReq .= 'AND P.post_id ' . $this->con->in($params['post_id']);
         }
 
@@ -875,13 +871,13 @@
                 $params['exclude_post_id'] = array((integer) $params['exclude_post_id']);
             }
-            $sql->where('P.post_id NOT ' . $sql->in($params['exclude_post_id']));
+            $strReq .= 'AND P.post_id NOT ' . $this->con->in($params['exclude_post_id']);
         }
 
         if (isset($params['post_url']) && $params['post_url'] !== '') {
-            $sql->where('post_url = ' . $sql->quote($params['post_url']));
+            $strReq .= "AND post_url = '" . $this->con->escape($params['post_url']) . "' ";
         }
 
         if (!empty($params['user_id'])) {
-            $sql->where('U.user_id = ' . $sql->quote($params['user_id']));
+            $strReq .= "AND U.user_id = '" . $this->con->escape($params['user_id']) . "' ";
         }
 
@@ -893,5 +889,5 @@
                 array_walk($params['cat_id'], function (&$v, $k) {$v = $v . " ?not";});
             }
-            $sql->where($this->getPostsCategoryFilter($params['cat_id'], 'cat_id'));
+            $strReq .= 'AND ' . $this->getPostsCategoryFilter($params['cat_id'], 'cat_id') . ' ';
         } elseif (isset($params['cat_url']) && $params['cat_url'] !== '') {
             if (!is_array($params['cat_url'])) {
@@ -901,34 +897,37 @@
                 array_walk($params['cat_url'], function (&$v, $k) {$v = $v . " ?not";});
             }
-            $sql->where($this->getPostsCategoryFilter($params['cat_url'], 'cat_url'));
+            $strReq .= 'AND ' . $this->getPostsCategoryFilter($params['cat_url'], 'cat_url') . ' ';
         }
 
         /* Other filters */
         if (isset($params['post_status'])) {
-            $sql->where('post_status = ' . (integer) $params['post_status']);
+            $strReq .= 'AND post_status = ' . (integer) $params['post_status'] . ' ';
         }
 
         if (isset($params['post_firstpub'])) {
-            $sql->where('post_firstpub = ' . (integer) $params['post_firstpub']);
+            $strReq .= 'AND post_firstpub = ' . (integer) $params['post_firstpub'] . ' ';
         }
 
         if (isset($params['post_selected'])) {
-            $sql->where('post_selected = ' . (integer) $params['post_selected']);
+            $strReq .= 'AND post_selected = ' . (integer) $params['post_selected'] . ' ';
         }
 
         if (!empty($params['post_year'])) {
-            $sql->where($sql->dateFormat('post_dt', '%Y') . ' = ' . "'" . sprintf('%04d', $params['post_year']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%Y') . ' = ' .
+            "'" . sprintf('%04d', $params['post_year']) . "' ";
         }
 
         if (!empty($params['post_month'])) {
-            $sql->where($sql->dateFormat('post_dt', '%m') . ' = ' . "'" . sprintf('%02d', $params['post_month']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%m') . ' = ' .
+            "'" . sprintf('%02d', $params['post_month']) . "' ";
         }
 
         if (!empty($params['post_day'])) {
-            $sql->where($sql->dateFormat('post_dt', '%d') . ' = ' . "'" . sprintf('%02d', $params['post_day']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%d') . ' = ' .
+            "'" . sprintf('%02d', $params['post_day']) . "' ";
         }
 
         if (!empty($params['post_lang'])) {
-            $sql->where('P.post_lang = ' . $sql->quote($params['post_lang']));
+            $strReq .= "AND P.post_lang = '" . $this->con->escape($params['post_lang']) . "' ";
         }
 
@@ -944,7 +943,7 @@
                 if ($words) {
                     foreach ($words as $i => $w) {
-                        $words[$i] = "post_words LIKE '%" . $sql->escape($w) . "%'";
+                        $words[$i] = "post_words LIKE '%" . $this->con->escape($w) . "%'";
                     }
-                    $sql->where(implode(' AND ', $words));
+                    $strReq .= 'AND ' . implode(' AND ', $words) . ' ';
                 }
             }
@@ -952,41 +951,42 @@
 
         if (isset($params['media'])) {
-            $sqlEx = new dcSelectStatement($this->core, 'coreGetPostsMedia');
-            $sqlEx
-                ->columns('M.post_id')
-                ->from($this->prefix . 'post_media M')
-                ->where('M.post_id = P.post_id');
+            if ($params['media'] == '0') {
+                $strReq .= 'AND NOT ';
+            } else {
+                $strReq .= 'AND ';
+            }
+            $strReq .= 'EXISTS (SELECT M.post_id FROM ' . $this->prefix . 'post_media M ' .
+                'WHERE M.post_id = P.post_id ';
             if (isset($params['link_type'])) {
-                $sqlEx->where('M.link_type ' . $sql->in($params['link_type']));
-            }
-            $sql->where(($params['media'] == '0' ? 'NOT ' : '') . 'EXISTS (' . $sqlEx->statement() . ')');
+                $strReq .= " AND M.link_type " . $this->con->in($params['link_type']) . " ";
+            }
+            $strReq .= ")";
         }
 
         if (!empty($params['where'])) {
-            $sql->cond($params['where']);
+            $strReq .= $params['where'] . ' ';
         }
 
         if (!empty($params['sql'])) {
-            $sql->sql($params['sql']);
+            $strReq .= $params['sql'] . ' ';
         }
 
         if (!$count_only) {
             if (!empty($params['order'])) {
-                $sql->order($sql->escape($params['order']));
+                $strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
             } else {
-                $sql->order('post_dt DESC');
-            }
-            if (!empty($params['limit'])) {
-                $sql->limit($params['limit']);
-            }
-        }
-
-        $query = $sql->statement();
+                $strReq .= 'ORDER BY post_dt DESC ';
+            }
+        }
+
+        if (!$count_only && !empty($params['limit'])) {
+            $strReq .= $this->con->limit($params['limit']);
+        }
 
         if (!empty($params['sql_only'])) {
-            return $query;
-        }
-
-        $rs            = $this->con->select($query);
+            return $strReq;
+        }
+
+        $rs            = $this->con->select($strReq);
         $rs->core      = $this->core;
         $rs->_nb_media = array();
@@ -1070,42 +1070,38 @@
     public function getLangs($params = array())
     {
-        $sql = new dcSelectStatement($this->core, 'coreGetLangs');
-        $sql
-            ->columns(array('COUNT(post_id) as nb_post', 'post_lang'))
-            ->from($this->prefix . 'post')
-            ->where(array(
-                'blog_id = ' . $sql->quote($this->id),
-                "post_lang <> ''",
-                'post_lang IS NOT NULL'
-            ));
+        $strReq = 'SELECT COUNT(post_id) as nb_post, post_lang ' .
+        'FROM ' . $this->prefix . 'post ' .
+        "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+            "AND post_lang <> '' " .
+            "AND post_lang IS NOT NULL ";
 
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $cond = '((post_status = 1';
+            $strReq .= 'AND ((post_status = 1 ';
 
             if ($this->without_password) {
-                $cond .= ' AND post_password IS NULL';
-            }
-            $cond .= ')';
+                $strReq .= 'AND post_password IS NULL ';
+            }
+            $strReq .= ') ';
 
             if ($this->core->auth->userID()) {
-                $cond .= " OR user_id = " . $sql->quote($this->core->auth->userID());
-            }
-            $cond .= ')';
-            $sql->where($cond);
+                $strReq .= "OR user_id = '" . $this->con->escape($this->core->auth->userID()) . "')";
+            } else {
+                $strReq .= ') ';
+            }
         }
 
         if (isset($params['post_type'])) {
             if ($params['post_type'] != '') {
-                $sql->where("post_type = " . $sql->quote($params['post_type']));
+                $strReq .= "AND post_type = '" . $this->con->escape($params['post_type']) . "' ";
             }
         } else {
-            $sql->where("post_type = 'post'");
+            $strReq .= "AND post_type = 'post' ";
         }
 
         if (isset($params['lang'])) {
-            $sql->where("post_lang = " . $sql->quote($params['lang']));
-        }
-
-        $sql->group('post_lang');
+            $strReq .= "AND post_lang = '" . $this->con->escape($params['lang']) . "' ";
+        }
+
+        $strReq .= 'GROUP BY post_lang ';
 
         $order = 'desc';
@@ -1113,7 +1109,7 @@
             $order = $params['order'];
         }
-        $sql->order('post_lang ' . $order);
-
-        return $this->con->select($sql->statement());
+        $strReq .= 'ORDER BY post_lang ' . $order . ' ';
+
+        return $this->con->select($strReq);
     }
 
@@ -1138,6 +1134,4 @@
     public function getDates($params = array())
     {
-        $sql = new dcSelectStatement($this->core, 'coreGetDates');
-
         $dt_f  = '%Y-%m-%d';
         $dt_fc = '%Y%m%d';
@@ -1154,59 +1148,56 @@
         $dt_fc .= '000000';
 
-        $sql
-            ->distinct()
-            ->columns(array(
-                $sql->dateFormat('post_dt', $dt_f) . ' AS dt',
-                'COUNT(P.post_id) AS nb_post'
-            ))
-            ->from($this->prefix . 'post P')
-            ->join('LEFT JOIN ' . $this->prefix . 'category C ON P.cat_id = C.cat_id')
-            ->group('dt');
+        $cat_field = $catReq = $limit = '';
 
         if (isset($params['cat_id']) && $params['cat_id'] !== '') {
-            $sql
-                ->columns('C.cat_url')
-                ->where('P.cat_id = ' . (integer) $params['cat_id'])
-                ->group('C.car_url');
+            $catReq    = 'AND P.cat_id = ' . (integer) $params['cat_id'] . ' ';
+            $cat_field = ', C.cat_url ';
         } elseif (isset($params['cat_url']) && $params['cat_url'] !== '') {
-            $sql
-                ->columns('C.cat_url')
-                ->where('C.cat_url = ' . $sql->quote($params['cat_url']))
-                ->group('C.car_url');
+            $catReq    = "AND C.cat_url = '" . $this->con->escape($params['cat_url']) . "' ";
+            $cat_field = ', C.cat_url ';
         }
         if (!empty($params['post_lang'])) {
-            $sql->where('P.post_lang = ' . $sql->quote($params['post_lang']));
-        }
+            $catReq = 'AND P.post_lang = \'' . $params['post_lang'] . '\' ';
+        }
+
+        $strReq = 'SELECT DISTINCT(' . $this->con->dateFormat('post_dt', $dt_f) . ') AS dt ' .
+        $cat_field .
+        ',COUNT(P.post_id) AS nb_post ' .
+        'FROM ' . $this->prefix . 'post P LEFT JOIN ' . $this->prefix . 'category C ' .
+        'ON P.cat_id = C.cat_id ' .
+        "WHERE P.blog_id = '" . $this->con->escape($this->id) . "' " .
+            $catReq;
 
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $cond = '((post_status = 1';
+            $strReq .= 'AND ((post_status = 1 ';
+
             if ($this->without_password) {
-                $cond .= ' AND post_password IS NULL';
-            }
-            $cond .= ')';
+                $strReq .= 'AND post_password IS NULL ';
+            }
+            $strReq .= ') ';
 
             if ($this->core->auth->userID()) {
-                $cond .= ' OR P.user_id = ' . $sql->quote($this->core->auth->userID());
-            }
-            $cond .= ')';
-            $sql->where($cond);
+                $strReq .= "OR P.user_id = '" . $this->con->escape($this->core->auth->userID()) . "')";
+            } else {
+                $strReq .= ') ';
+            }
         }
 
         if (!empty($params['post_type'])) {
-            $sql->where("post_type " . $sql->in($params['post_type']));
+            $strReq .= "AND post_type " . $this->con->in($params['post_type']) . " ";
         } else {
-            $sql->where("post_type = 'post'");
+            $strReq .= "AND post_type = 'post' ";
         }
 
         if (!empty($params['year'])) {
-            $sql->where($sql->dateFormat('post_dt', '%Y') . " = '" . sprintf('%04d', $params['year']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%Y') . " = '" . sprintf('%04d', $params['year']) . "' ";
         }
 
         if (!empty($params['month'])) {
-            $sql->where($sql->dateFormat('post_dt', '%m') . " = '" . sprintf('%02d', $params['month']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%m') . " = '" . sprintf('%02d', $params['month']) . "' ";
         }
 
         if (!empty($params['day'])) {
-            $sql->where($sql->dateFormat('post_dt', '%d') . " = '" . sprintf('%02d', $params['day']) . "'");
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', '%d') . " = '" . sprintf('%02d', $params['day']) . "' ";
         }
 
@@ -1225,8 +1216,9 @@
             $dt = date('YmdHis', strtotime($dt));
 
-            $sql
-                ->where($sql->dateFormat('post_dt', $dt_fc) . $pdir . "'" . $dt . "'")
-                ->limit(1);
-        }
+            $strReq .= 'AND ' . $this->con->dateFormat('post_dt', $dt_fc) . $pdir . "'" . $dt . "' ";
+            $limit = $this->con->limit(1);
+        }
+
+        $strReq .= 'GROUP BY dt ' . $cat_field;
 
         $order = 'desc';
@@ -1234,7 +1226,10 @@
             $order = $params['order'];
         }
-        $sql->order('dt ' . $order);
-
-        $rs = $this->con->select($sql->statement());
+
+        $strReq .=
+            'ORDER BY dt ' . $order . ' ' .
+            $limit;
+
+        $rs = $this->con->select($strReq);
         $rs->extend('rsExtDates');
         return $rs;
@@ -1258,10 +1253,8 @@
         {
             # Get ID
-            $sql = new dcSelectStatement($this->core, 'corePostCreateGetID');
-            $sql
-                ->columns('MAX(post_id)')
-                ->from($this->prefix . 'post');
-
-            $rs = $this->con->select($sql->statement());
+            $rs = $this->con->select(
+                'SELECT MAX(post_id) ' .
+                'FROM ' . $this->prefix . 'post '
+            );
 
             $cur->post_id     = (integer) $rs->f(0) + 1;
@@ -1335,17 +1328,12 @@
         $cur->post_upddt = date('Y-m-d H:i:s');
 
-        // If user is only "usage", we need to check the post's owner
+        #If user is only "usage", we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sql = new dcSelectStatement($this->core, 'corePostUpdateCheckOwner');
-            $sql
-                ->column('post_id')
-                ->from($this->prefix . 'post')
-                ->where(array(
-                    'post_id = ' . $id,
-                    'user_id = ' . $sql->quote($this->core->auth->userID())
-                ));
-
-            $rs = $this->con->select($sql->statement());
-            unset($sql);
+            $strReq = 'SELECT post_id ' .
+            'FROM ' . $this->prefix . 'post ' .
+            'WHERE post_id = ' . $id . ' ' .
+            "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
+
+            $rs = $this->con->select($strReq);
 
             if ($rs->isEmpty()) {
@@ -1357,8 +1345,5 @@
         $this->core->callBehavior('coreBeforePostUpdate', $this, $cur);
 
-        $sql = new dcUpdateStatement($this->core, 'corePostUpdate');
-        $sql->where('post_id = ' . $id);
-
-        $cur->update($sql->whereStatement());
+        $cur->update('WHERE post_id = ' . $id . ' ');
 
         # --BEHAVIOR-- coreAfterPostUpdate
@@ -1396,14 +1381,10 @@
         $status    = (integer) $status;
 
-        $sql = new dcUpdateStatement($this->core, 'coreUpdPostsStatus');
-        $sql
-            ->where(array(
-                'blog_id = ' . $sql->quote($this->id),
-                'post_id ' . $sql->in($posts_ids)
-            ));
+        $strReq = "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+        "AND post_id " . $this->con->in($posts_ids);
 
         #If user can only publish, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sql->where('user_id = ' . $sql->quote($this->core->auth->userID()));
+            $strReq .= "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
         }
 
@@ -1413,5 +1394,5 @@
         $cur->post_upddt  = date('Y-m-d H:i:s');
 
-        $cur->update($sql->whereStatement());
+        $cur->update($strReq);
         $this->triggerBlog();
 
@@ -1445,14 +1426,10 @@
         $selected  = (boolean) $selected;
 
-        $sql = new dcUpdateStatement($this->core, 'coreUpdPostsSelected');
-        $sql
-            ->where(array(
-                'blog_id = ' . $sql->quote($this->id),
-                'post_id ' . $sql->in($posts_ids)
-            ));
+        $strReq = "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+        "AND post_id " . $this->con->in($posts_ids);
 
         # If user is only usage, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sql->where('user_id = ' . $sql->quote($this->core->auth->userID()));
+            $strReq .= "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
         }
 
@@ -1462,5 +1439,5 @@
         $cur->post_upddt    = date('Y-m-d H:i:s');
 
-        $cur->update($sql->whereStatement());
+        $cur->update($strReq);
         $this->triggerBlog();
     }
@@ -1492,14 +1469,10 @@
         $cat_id    = (integer) $cat_id;
 
-        $sql = new dcUpdateStatement($this->core, 'coreUpdPostsCategory');
-        $sql
-            ->where(array(
-                'blog_id = ' . $sql->quote($this->id),
-                'post_id ' . $sql->in($posts_ids)
-            ));
-
-        // If user is only usage, we need to check the post's owner
+        $strReq = "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+        "AND post_id " . $this->con->in($posts_ids);
+
+        # If user is only usage, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sql->where('user_id = ' . $sql->quote($this->core->auth->userID()));
+            $strReq .= "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
         }
 
@@ -1509,5 +1482,5 @@
         $cur->post_upddt = date('Y-m-d H:i:s');
 
-        $cur->update($sql->whereStatement());
+        $cur->update($strReq);
         $this->triggerBlog();
     }
@@ -1533,11 +1506,8 @@
         $cur->post_upddt = date('Y-m-d H:i:s');
 
-        $sql = new dcUpdateStatement($this->core, 'coreChangePostsCategory');
-        $sql
-            ->where(array(
-                'cat_id = ' . $old_cat_id,
-                'blog_id = ' . $sql->quote($this->id)
-            ));
-        $cur->update($sql->whereStatement());
+        $cur->update(
+            'WHERE cat_id = ' . $old_cat_id . ' ' .
+            "AND blog_id = '" . $this->con->escape($this->id) . "' "
+        );
         $this->triggerBlog();
     }
@@ -1570,18 +1540,14 @@
         }
 
-        $sql = new dcDeleteStatement($this->core, 'coreDelPosts');
-        $sql
-            ->from($this->prefix . 'post')
-            ->where(array(
-                'blog_id = ' . $sql->quote($this->id),
-                'post_id ' . $sql->in($posts_ids)
-            ));
-
-        // If user can only delete, we need to check the post's owner
+        $strReq = 'DELETE FROM ' . $this->prefix . 'post ' .
+        "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+        "AND post_id " . $this->con->in($posts_ids);
+
+        #If user can only delete, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sql->where('user_id = ' . $sql->quote($this->core->auth->userID()));
-        }
-
-        $this->con->execute($sql->statement());
+            $strReq .= "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
+        }
+
+        $this->con->execute($strReq);
         $this->triggerBlog();
     }
@@ -1592,15 +1558,10 @@
     public function publishScheduledEntries()
     {
-        $sql = new dcSelectStatement($this->core, 'coreScheduledEntriesPublish');
-        $sql
-            ->columns(array('post_id', 'post_dt', 'post_tz'))
-            ->from($this->prefix . 'post')
-            ->where(array(
-                'post_status = -1',
-                'blog_id = ' . $sql->quote($this->id)
-            ));
-
-        $rs = $this->con->select($sql->statement());
-        unset($sql);
+        $strReq = 'SELECT post_id, post_dt, post_tz ' .
+        'FROM ' . $this->prefix . 'post ' .
+        'WHERE post_status = -1 ' .
+        "AND blog_id = '" . $this->con->escape($this->id) . "' ";
+
+        $rs = $this->con->select($strReq);
 
         $now       = dt::toUTC(time());
@@ -1627,14 +1588,10 @@
             $this->core->callBehavior('coreBeforeScheduledEntriesPublish', $this, $to_change);
 
-            $sql = new dcUpdateStatement($this->core, 'coreScheduledEntriesPublish');
-            $sql
-                ->reference($this->prefix . 'post')
-                ->set('post_status = 1')
-                ->where(array(
-                    'blog_id = ' . $sql->quote($this->id),
-                    'post_id ' . $sql->in((array) $to_change)
-                ));
-
-            $this->con->execute($sql->statement());
+            $strReq =
+            'UPDATE ' . $this->prefix . 'post SET ' .
+            'post_status = 1 ' .
+            "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+            'AND post_id ' . $this->con->in((array) $to_change) . ' ';
+            $this->con->execute($strReq);
             $this->triggerBlog();
 
@@ -1667,14 +1624,10 @@
         if (count($to_change)) {
 
-            $sql = new dcUpdateStatement($this->core, 'coreFirstPublicationEntries');
-            $sql
-                ->reference($this->prefix . 'post')
-                ->set('post_firstpub = 1')
-                ->where(array(
-                    'blog_id = ' . $sql->quote($this->id),
-                    'post_id ' . $sql->in((array) $to_change)
-                ));
-
-            $this->con->execute($sql->statement());
+            $strReq =
+            'UPDATE ' . $this->prefix . 'post ' .
+            'SET post_firstpub = 1 ' .
+            "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+            'AND post_id ' . $this->con->in((array) $to_change) . ' ';
+            $this->con->execute($strReq);
 
             # --BEHAVIOR-- coreFirstPublicationEntries
@@ -1691,20 +1644,17 @@
     public function getPostsUsers($post_type = 'post')
     {
-        $sql = new dcSelectStatement($this->core, 'coreGetPostsUsers');
-        $sql
-            ->columns(array('P.user_id', 'user_name', 'user_firstname', 'user_displayname', 'user_email'))
-            ->from(array($this->prefix . 'post P', $this->prefix . 'user U'))
-            ->where(array(
-                'P.user_id = U.user_id',
-                'blog_id = ' . $sql->quote($this->id)
-            ));
+        $strReq = 'SELECT P.user_id, user_name, user_firstname, ' .
+        'user_displayname, user_email ' .
+        'FROM ' . $this->prefix . 'post P, ' . $this->prefix . 'user U ' .
+        'WHERE P.user_id = U.user_id ' .
+        "AND blog_id = '" . $this->con->escape($this->id) . "' ";
 
         if ($post_type) {
-            $sql->where("post_type = '" . $sql->escape($post_type) . "'");
-        }
-
-        $sql->group(array('P.user_id', 'user_name', 'user_firstname', 'user_displayname', 'user_email'));
-
-        return $this->con->select($sql->statement());
+            $strReq .= "AND post_type = '" . $this->con->escape($post_type) . "' ";
+        }
+
+        $strReq .= 'GROUP BY P.user_id, user_name, user_firstname, user_displayname, user_email ';
+
+        return $this->con->select($strReq);
     }
 
@@ -1737,18 +1687,13 @@
 
         if (!empty($sub)) {
-            $sql = new dcSelectStatement($this->core);
-            $sql
-                ->columns(array('cat_id', 'cat_url', 'cat_lft', 'cat_rgt'))
-                ->from($this->prefix . 'category')
-                ->where(array(
-                    'blog_id = ' . $sql->quote($this->id),
-                    $field . ' ' . $sql->in(array_keys($sub))
-                ));
-            $rs = $this->con->select($sql->statement());
+            $rs = $this->con->select(
+                'SELECT cat_id, cat_url, cat_lft, cat_rgt FROM ' . $this->prefix . 'category ' .
+                "WHERE blog_id = '" . $this->con->escape($this->id) . "' " .
+                'AND ' . $field . ' ' . $this->con->in(array_keys($sub))
+            );
 
             while ($rs->fetch()) {
                 $queries[$rs->f($field)] = '(C.cat_lft BETWEEN ' . $rs->cat_lft . ' AND ' . $rs->cat_rgt . ')';
             }
-            unset($sql);
         }
 
@@ -1936,22 +1881,29 @@
 
         # Let's check if URL is taken...
-        $sql = new dcSelectStatement($this->core, 'coreGetPostURL');
-        $sql
-            ->columns('post_url')
-            ->from($this->prefix . 'post')
-            ->where(array(
-                'post_id <> ' . (integer) $post_id,
-                'blog_id = ' . $sql->quote($this->id)
-            ))
-            ->cond('AND post_url = ' . $sql->quote($url))
-            ->order('post_url DESC');
-
-        $rs = $this->con->select($sql->statement());
+        $strReq = 'SELECT post_url FROM ' . $this->prefix . 'post ' .
+        "WHERE post_url = '" . $this->con->escape($url) . "' " .
+        'AND post_id <> ' . (integer) $post_id . ' ' .
+        "AND blog_id = '" . $this->con->escape($this->id) . "' " .
+            'ORDER BY post_url DESC';
+
+        $rs = $this->con->select($strReq);
 
         if (!$rs->isEmpty()) {
-            // Replace condition on post_url
-            $sql->cond('AND post_url ' . $sql->regexp($url), true);
-
-            $rs = $this->con->select($sql->statement());
+            if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') {
+                $clause = "REGEXP '^" . $this->con->escape(preg_quote($url)) . "[0-9]+$'";
+            } elseif ($this->con->driver() == 'pgsql') {
+                $clause = "~ '^" . $this->con->escape(preg_quote($url)) . "[0-9]+$'";
+            } else {
+                $clause = "LIKE '" .
+                $this->con->escape(preg_replace(array('%', '_', '!'), array('!%', '!_', '!!'), $url)) .
+                    "%' ESCAPE '!'";
+            }
+            $strReq = 'SELECT post_url FROM ' . $this->prefix . 'post ' .
+            "WHERE post_url " . $clause . ' ' .
+            'AND post_id <> ' . (integer) $post_id . ' ' .
+            "AND blog_id = '" . $this->con->escape($this->id) . "' " .
+                'ORDER BY post_url DESC ';
+
+            $rs = $this->con->select($strReq);
             $a  = array();
             while ($rs->fetch()) {
@@ -2011,60 +1963,65 @@
     public function getComments($params = array(), $count_only = false)
     {
-        $sql = new dcSelectStatement($this->core, 'coreGetComments');
-
         if ($count_only) {
-            $sql->columns('count(comment_id)');
+            $strReq = 'SELECT count(comment_id) ';
         } elseif (!empty($params['sql_only'])) {
-            $sql->columns('P.post_id');
+            $strReq = 'SELECT P.post_id ';
         } else {
-            if (empty($params['no_content'])) {
-                $sql->columns('comment_content');
+            if (!empty($params['no_content'])) {
+                $content_req = '';
+            } else {
+                $content_req = 'comment_content, ';
             }
 
             if (!empty($params['columns']) && is_array($params['columns'])) {
-                $sql->columns($params['columns']);
-            }
-
-            $sql->columns(array('C.comment_id', 'comment_dt', 'comment_tz', 'comment_upddt', 'comment_author', 'comment_email', 'comment_site', 'comment_trackback', 'comment_status', 'comment_spam_status', 'comment_spam_filter', 'comment_ip', 'P.post_title', 'P.post_url', 'P.post_id', 'P.post_password', 'P.post_type', 'P.post_dt', 'P.user_id', 'U.user_email', 'U.user_url'));
-        }
-
-        $sql
-            ->from($this->prefix . 'comment C')
-            ->join(array(
-                'INNER JOIN ' . $this->prefix . 'post P ON C.post_id = P.post_id',
-                'INNER JOIN ' . $this->prefix . 'user U ON P.user_id = U.user_id '
-            ));
+                $content_req .= implode(', ', $params['columns']) . ', ';
+            }
+
+            $strReq =
+                'SELECT C.comment_id, comment_dt, comment_tz, comment_upddt, ' .
+                'comment_author, comment_email, comment_site, ' .
+                $content_req . ' comment_trackback, comment_status, ' .
+                'comment_spam_status, comment_spam_filter, comment_ip, ' .
+                'P.post_title, P.post_url, P.post_id, P.post_password, P.post_type, ' .
+                'P.post_dt, P.user_id, U.user_email, U.user_url ';
+        }
+
+        $strReq .=
+        'FROM ' . $this->prefix . 'comment C ' .
+        'INNER JOIN ' . $this->prefix . 'post P ON C.post_id = P.post_id ' .
+        'INNER JOIN ' . $this->prefix . 'user U ON P.user_id = U.user_id ';
 
         if (!empty($params['from'])) {
-            $sql->from($params['from']);
-        }
-
-        $sql->where('P.blog_id = ' . $sql->quote($this->id));
+            $strReq .= $params['from'] . ' ';
+        }
+
+        $strReq .=
+        "WHERE P.blog_id = '" . $this->con->escape($this->id) . "' ";
 
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $cond = '((comment_status = 1 AND P.post_status = 1';
+            $strReq .= 'AND ((comment_status = 1 AND P.post_status = 1 ';
 
             if ($this->without_password) {
-                $cond .= ' AND post_password IS NULL';
-            }
-            $cond .= ')';
+                $strReq .= 'AND post_password IS NULL ';
+            }
+            $strReq .= ') ';
 
             if ($this->core->auth->userID()) {
-                $cond .= ' OR P.user_id = ' . $sql->quote($this->core->auth->userID());
-            }
-            $cond .= ')';
-            $sql->where($cond);
+                $strReq .= "OR P.user_id = '" . $this->con->escape($this->core->auth->userID()) . "')";
+            } else {
+                $strReq .= ') ';
+            }
         }
 
         if (!empty($params['post_type'])) {
-            $sql->where('post_type ' . $sql->in($params['post_type']));
+            $strReq .= 'AND post_type ' . $this->con->in($params['post_type']);
         }
 
         if (isset($params['post_id']) && $params['post_id'] !== '') {
-            $sql->where('P.post_id = ' . (integer) $params['post_id']);
+            $strReq .= 'AND P.post_id = ' . (integer) $params['post_id'] . ' ';
         }
 
         if (isset($params['cat_id']) && $params['cat_id'] !== '') {
-            $sql->where('P.cat_id = ' . (integer) $params['cat_id']);
+            $strReq .= 'AND P.cat_id = ' . (integer) $params['cat_id'] . ' ';
         }
 
@@ -2075,37 +2032,37 @@
                 $params['comment_id'] = array((integer) $params['comment_id']);
             }
-            $sql->where('comment_id ' . $sql->in($params['comment_id']));
+            $strReq .= 'AND comment_id ' . $this->con->in($params['comment_id']);
         }
 
         if (isset($params['comment_email'])) {
-            $comment_email = $sql->quote(str_replace('*', '%', $params['comment_email']));
-            $sql->where('comment_email LIKE ' . $comment_email);
+            $comment_email = $this->con->escape(str_replace('*', '%', $params['comment_email']));
+            $strReq .= "AND comment_email LIKE '" . $comment_email . "' ";
         }
 
         if (isset($params['comment_site'])) {
-            $comment_site = $sql->quote(str_replace('*', '%', $params['comment_site']));
-            $sql->where('comment_site LIKE ' . $comment_site);
+            $comment_site = $this->con->escape(str_replace('*', '%', $params['comment_site']));
+            $strReq .= "AND comment_site LIKE '" . $comment_site . "' ";
         }
 
         if (isset($params['comment_status'])) {
-            $sql->where('comment_status = ' . (integer) $params['comment_status']);
+            $strReq .= 'AND comment_status = ' . (integer) $params['comment_status'] . ' ';
         }
 
         if (!empty($params['comment_status_not'])) {
-            $sql->where('comment_status <> ' . (integer) $params['comment_status_not']);
+            $strReq .= 'AND comment_status <> ' . (integer) $params['comment_status_not'] . ' ';
         }
 
         if (isset($params['comment_trackback'])) {
-            $sql->where('comment_trackback = ' . (integer) (boolean) $params['comment_trackback']);
+            $strReq .= 'AND comment_trackback = ' . (integer) (boolean) $params['comment_trackback'] . ' ';
         }
 
         if (isset($params['comment_ip'])) {
-            $comment_ip = $sql->quote(str_replace('*', '%', $params['comment_ip']));
-            $sql->where('comment_ip LIKE ' . $comment_ip);
+            $comment_ip = $this->con->escape(str_replace('*', '%', $params['comment_ip']));
+            $strReq .= "AND comment_ip LIKE '" . $comment_ip . "' ";
         }
 
         if (isset($params['q_author'])) {
-            $q_author = $sql->quote(str_replace('*', '%', strtolower($params['q_author'])));
-            $sql->where('LOWER(comment_author) LIKE ' . $q_author);
+            $q_author = $this->con->escape(str_replace('*', '%', strtolower($params['q_author'])));
+            $strReq .= "AND LOWER(comment_author) LIKE '" . $q_author . "' ";
         }
 
@@ -2121,7 +2078,7 @@
                 if ($words) {
                     foreach ($words as $i => $w) {
-                        $words[$i] = "comment_words LIKE '%" . $sql->escape($w) . "%'";
+                        $words[$i] = "comment_words LIKE '%" . $this->con->escape($w) . "%'";
                     }
-                    $sql->where(implode(' AND ', $words));
+                    $strReq .= 'AND ' . implode(' AND ', $words) . ' ';
                 }
             }
@@ -2129,26 +2086,24 @@
 
         if (!empty($params['sql'])) {
-            $sql->sql($params['sql']);
+            $strReq .= $params['sql'] . ' ';
         }
 
         if (!$count_only) {
             if (!empty($params['order'])) {
-                $sql->order($sql->escape($params['order']));
+                $strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
             } else {
-                $sql->order('comment_dt DESC');
+                $strReq .= 'ORDER BY comment_dt DESC ';
             }
         }
 
         if (!$count_only && !empty($params['limit'])) {
-            $sql->limit($params['limit']);
-        }
-
-        $query = $sql->statement();
+            $strReq .= $this->con->limit($params['limit']);
+        }
 
         if (!empty($params['sql_only'])) {
-            return $query;
-        }
-
-        $rs       = $this->con->select($query);
+            return $strReq;
+        }
+
+        $rs       = $this->con->select($strReq);
         $rs->core = $this->core;
         $rs->extend('rsExtComment');
@@ -2173,9 +2128,8 @@
         {
             # Get ID
-            $sql = new dcSelectStatement($this->core, 'coreCommentCreateGetID');
-            $sql
-                ->columns('MAX(comment_id)')
-                ->from($this->prefix . 'comment');
-            $rs = $this->con->select($sql->statement());
+            $rs = $this->con->select(
+                'SELECT MAX(comment_id) ' .
+                'FROM ' . $this->prefix . 'comment '
+            );
 
             $cur->comment_id    = (integer) $rs->f(0) + 1;
@@ -2254,8 +2208,5 @@
         $this->core->callBehavior('coreBeforeCommentUpdate', $this, $cur, $rs);
 
-        $sql = new dcUpdateStatement($this->core, 'coreCommentUpdate');
-        $sql->where('comment_id = ' . $id);
-
-        $cur->update($sql->whereStatement());
+        $cur->update('WHERE comment_id = ' . $id . ' ');
 
         # --BEHAVIOR-- coreAfterCommentUpdate
@@ -2292,23 +2243,18 @@
         $status = (integer) $status;
 
-        $sqlIn = new dcSelectStatement($this->core, 'coreUpdCommentsStatusIn');
-        $sqlIn
-            ->columns('tp.post_id')
-            ->from($this->prefix . 'post tp')
-            ->where('tp.blog_id = ' . $sqlIn->quote($this->id));
+        $strReq =
+        'UPDATE ' . $this->prefix . 'comment ' .
+            'SET comment_status = ' . $status . ' ';
+        $strReq .=
+        'WHERE comment_id' . $this->con->in($co_ids) .
+        'AND post_id in (SELECT tp.post_id ' .
+        'FROM ' . $this->prefix . 'post tp ' .
+        "WHERE tp.blog_id = '" . $this->con->escape($this->id) . "' ";
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sqlIn->where('user_id = ' . $sqlIn->quote($this->core->auth->userID()));
-        }
-
-        $sql = new dcUpdateStatement($this->core, 'coreUpdCommentsStatus');
-        $sql
-            ->reference($this->prefix . 'comment')
-            ->set('comment_status = ' . $status)
-            ->where(array(
-                'comment_id ' . $sql->in($co_ids),
-                'post_id in (' . $sqlIn->statement() . ')'
-            ));
-
-        $this->con->execute($sql->statement());
+            $strReq .=
+            "AND user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
+        }
+        $strReq .= ')';
+        $this->con->execute($strReq);
         $this->triggerComments($co_ids);
         $this->triggerBlog();
@@ -2344,14 +2290,11 @@
         # Retrieve posts affected by comments edition
         $affected_posts = array();
-
-        $sql = new dcSelectStatement($this->core, 'coreDelCommentsScope');
-        $sql
-            ->column('post_id')
-            ->from($this->prefix . 'comment')
-            ->where('comment_id' . $sql->in($co_ids))
-            ->group('post_id');
-
-        $rs = $this->con->select($sql->statement());
-        unset($sql);
+        $strReq         =
+        'SELECT post_id ' .
+        'FROM ' . $this->prefix . 'comment ' .
+        'WHERE comment_id' . $this->con->in($co_ids) .
+            'GROUP BY post_id';
+
+        $rs = $this->con->select($strReq);
 
         while ($rs->fetch()) {
@@ -2359,22 +2302,17 @@
         }
 
-        $sqlIn = new dcSelectStatement($this->core, 'coreDelCommentsIn');
-        $sqlIn
-            ->columns('tp.post_id')
-            ->from($this->prefix . 'post tp')
-            ->where(array('tp.blog_id = ' . $sqlIn->quote($this->id)));
+        $strReq =
+        'DELETE FROM ' . $this->prefix . 'comment ' .
+        'WHERE comment_id' . $this->con->in($co_ids) . ' ' .
+        'AND post_id in (SELECT tp.post_id ' .
+        'FROM ' . $this->prefix . 'post tp ' .
+        "WHERE tp.blog_id = '" . $this->con->escape($this->id) . "' ";
+        #If user can only delete, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            $sqlIn->where('tp.user_id = ' . $sqlIn->quote($this->core->auth->userID()));
-        }
-
-        $sql = new dcDeleteStatement($this->core, 'coreDelComments');
-        $sql
-            ->from($this->prefix . 'comment')
-            ->where(array(
-                'comment_id ' . $sql->in($co_ids),
-                'post_id in (' . $sqlIn->statement() . ')'
-            ));
-
-        $this->con->execute($sql->statement());
+            $strReq .=
+            "AND tp.user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
+        }
+        $strReq .= ")";
+        $this->con->execute($strReq);
         $this->triggerComments($co_ids, true, $affected_posts);
         $this->triggerBlog();
@@ -2387,23 +2325,17 @@
         }
 
-        $sqlIn = new dcSelectStatement($this->core, 'coreDelJunkCommentsIn');
-        $sqlIn
-            ->columns('tp.post_id')
-            ->from($this->prefix . 'post tp')
-            ->where('tp.blog_id = ' . $sqlIn->quote($this->id));
+        $strReq =
+        'DELETE FROM ' . $this->prefix . 'comment ' .
+        'WHERE comment_status = -2 ' .
+        'AND post_id in (SELECT tp.post_id ' .
+        'FROM ' . $this->prefix . 'post tp ' .
+        "WHERE tp.blog_id = '" . $this->con->escape($this->id) . "' ";
+        #If user can only delete, we need to check the post's owner
         if (!$this->core->auth->check('contentadmin', $this->id)) {
-            // If user can only delete, we need to check the post's owner
-            $sqlIn->where('tp.user_id = ' . $sqlIn->quote($this->core->auth->userID()));
-        }
-
-        $sql = new dcDeleteStatement($this->core, 'coreDelJunkComments');
-        $sql
-            ->from($this->prefix . 'comment')
-            ->where(array(
-                'comment_status = -2',
-                'post_id in (' . $sqlIn->statement() . ')'
-            ));
-
-        $this->con->execute($sql->statement());
+            $strReq .=
+            "AND tp.user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
+        }
+        $strReq .= ")";
+        $this->con->execute($strReq);
         $this->triggerBlog();
     }
Index: inc/core/class.dc.core.php
===================================================================
--- inc/core/class.dc.core.php	(revision 3761)
+++ inc/core/class.dc.core.php	(revision 3731)
@@ -442,10 +442,6 @@
         # Fetch versions if needed
         if (!is_array($this->versions)) {
-            $sql = new dcSelectStatement($this, 'coreGetVersion');
-            $sql
-                ->columns(array('module', 'version'))
-                ->from($this->prefix . 'version');
-
-            $rs     = $this->con->select($sql->statement());
+            $strReq = 'SELECT module, version FROM ' . $this->prefix . 'version';
+            $rs     = $this->con->select($strReq);
 
             while ($rs->fetch()) {
@@ -478,8 +474,5 @@
             $cur->insert();
         } else {
-            $sql = new dcUpdateStatement($this, 'coreSetVersion');
-            $sql->where('module=' . $sql->quote($module));
-
-            $cur->update($sql->whereStatement());
+            $cur->update("WHERE module='" . $this->con->escape($module) . "'");
         }
 
@@ -494,10 +487,9 @@
     public function delVersion($module)
     {
-        $sql = new dcDeleteStatement($this, 'coreDelVersion');
-        $sql
-            ->from($this->prefix . 'version')
-            ->where('module = ' . $sql->quote($module));
-
-        $this->con->execute($sql->statement());
+        $strReq =
+        'DELETE FROM ' . $this->prefix . 'version ' .
+        "WHERE module = '" . $this->con->escape($module) . "' ";
+
+        $this->con->execute($strReq);
 
         if (is_array($this->versions)) {
@@ -538,36 +530,37 @@
     public function getUsers($params = array(), $count_only = false)
     {
-        $sql = new dcSelectStatement($this, 'coreGetUsers');
-        $sql
-            ->from($this->prefix . 'user U')
-            ->where('NULL IS NULL');
-
         if ($count_only) {
-            $sql->columns('COUNT(U.user_id)');
+            $strReq =
+            'SELECT count(U.user_id) ' .
+            'FROM ' . $this->prefix . 'user U ' .
+                'WHERE NULL IS NULL ';
         } else {
-            $sql
-                ->columns(array('U.user_id', 'user_super', 'user_status', 'user_pwd', 'user_change_pwd', 'user_name',
-                    'user_firstname', 'user_displayname', 'user_email', 'user_url', 'user_desc', 'user_lang', 'user_tz',
-                    'user_post_status', 'user_options', 'COUNT(P.post_id) AS nb_post'))
-                ->join('LEFT JOIN ' . $this->prefix . 'post P ON U.user_id = P.user_id');
+            $strReq =
+            'SELECT U.user_id,user_super,user_status,user_pwd,user_change_pwd,' .
+            'user_name,user_firstname,user_displayname,user_email,user_url,' .
+            'user_desc, user_lang,user_tz, user_post_status,user_options, ' .
+            'count(P.post_id) AS nb_post ' .
+            'FROM ' . $this->prefix . 'user U ' .
+            'LEFT JOIN ' . $this->prefix . 'post P ON U.user_id = P.user_id ' .
+                'WHERE NULL IS NULL ';
         }
 
         if (!empty($params['q'])) {
-            $q = $sql->escape(str_replace('*', '%', strtolower($params['q'])));
-            $sql->where(
-                '(' .
+            $q = $this->con->escape(str_replace('*', '%', strtolower($params['q'])));
+            $strReq .= 'AND (' .
                 "LOWER(U.user_id) LIKE '" . $q . "' " .
                 "OR LOWER(user_name) LIKE '" . $q . "' " .
                 "OR LOWER(user_firstname) LIKE '" . $q . "' " .
-                ')'
-            );
+                ') ';
         }
 
         if (!empty($params['user_id'])) {
-            $sql->where('U.user_id = ' . $sql->quote($params['user_id']));
+            $strReq .= "AND U.user_id = '" . $this->con->escape($params['user_id']) . "' ";
         }
 
         if (!$count_only) {
-            $sql->group(array('U.user_id', 'user_super', 'user_status', 'user_pwd', 'user_change_pwd', 'user_name', 'user_firstname', 'user_displayname', 'user_email', 'user_url', 'user_desc', 'user_lang', 'user_tz', 'user_post_status', 'user_options'));
+            $strReq .= 'GROUP BY U.user_id,user_super,user_status,user_pwd,user_change_pwd,' .
+                'user_name,user_firstname,user_displayname,user_email,user_url,' .
+                'user_desc, user_lang,user_tz,user_post_status,user_options ';
 
             if (!empty($params['order']) && !$count_only) {
@@ -578,18 +571,17 @@
                         $table_prefix = ''; // order = nb_post (asc|desc)
                     }
-                    $sql->order($table_prefix . $sql->escape($params['order']));
+                    $strReq .= 'ORDER BY ' . $table_prefix . $this->con->escape($params['order']) . ' ';
                 } else {
-                    $sql->order($sql->escape($params['order']));
+                    $strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
                 }
             } else {
-                $sql->order('U.user_id ASC');
+                $strReq .= 'ORDER BY U.user_id ASC ';
             }
         }
 
         if (!$count_only && !empty($params['limit'])) {
-            $sql->limit($params['limit']);
-        }
-
-        $rs = $this->con->select($sql->statement());
+            $strReq .= $this->con->limit($params['limit']);
+        }
+        $rs = $this->con->select($strReq);
         $rs->extend('rsExtUser');
         return $rs;
@@ -645,9 +637,5 @@
         }
 
-        $sql = new dcUpdateStatement($this, 'coreUpdUser');
-        $sql
-            ->where('user_id = ' . $sql->quote($id));
-
-        $cur->update($sql->whereStatement());
+        $cur->update("WHERE user_id = '" . $this->con->escape($id) . "' ");
 
         $this->auth->afterUpdUser($id, $cur);
@@ -658,11 +646,8 @@
 
         # Updating all user's blogs
-        $sql = new dcSelectStatement($this, 'coreUpdUser');
-        $sql
-            ->columns('DISTINCT(blog_id)')
-            ->from($this->prefix . 'post')
-            ->where('user_id = ' . $sql->quote($id));
-
-        $rs = $this->con->select($sql->statement());
+        $rs = $this->con->select(
+            'SELECT DISTINCT(blog_id) FROM ' . $this->prefix . 'post ' .
+            "WHERE user_id = '" . $this->con->escape($id) . "' "
+        );
 
         while ($rs->fetch()) {
@@ -696,10 +681,8 @@
         }
 
-        $sql = new dcDeleteStatement($this, 'coreDelUser');
-        $sql
-            ->from($this->prefix . 'user')
-            ->where('user_id = ' . $sql->quote($id));
-
-        $this->con->execute($sql->statement());
+        $strReq = 'DELETE FROM ' . $this->prefix . 'user ' .
+        "WHERE user_id = '" . $this->con->escape($id) . "' ";
+
+        $this->con->execute($strReq);
 
         $this->auth->afterDelUser($id);
@@ -714,11 +697,9 @@
     public function userExists($id)
     {
-        $sql = new dcSelectStatement($this, 'coreUserExists');
-        $sql
-            ->columns('user_id')
-            ->from($this->prefix . 'user')
-            ->where('user_id = ' . $sql->quote($id));
-
-        $rs = $this->con->select($sql->statement());
+        $strReq = 'SELECT user_id ' .
+        'FROM ' . $this->prefix . 'user ' .
+        "WHERE user_id = '" . $this->con->escape($id) . "' ";
+
+        $rs = $this->con->select($strReq);
 
         return !$rs->isEmpty();
@@ -740,12 +721,10 @@
     public function getUserPermissions($id)
     {
-        $sql = new dcSelectStatement($this, 'coreGetUserPermissions');
-        $sql
-            ->columns(array('B.blog_id', 'blog_name', 'blog_url', 'permissions'))
-            ->from($this->prefix . 'permissions P')
-            ->join('INNER JOIN ' . $this->prefix . 'blog B ON P.blog_id = B.blog_id')
-            ->where('user_id = ' . $sql->quote($id));
-
-        $rs = $this->con->select($sql->statement());
+        $strReq = 'SELECT B.blog_id, blog_name, blog_url, permissions ' .
+        'FROM ' . $this->prefix . 'permissions P ' .
+        'INNER JOIN ' . $this->prefix . 'blog B ON P.blog_id = B.blog_id ' .
+        "WHERE user_id = '" . $this->con->escape($id) . "' ";
+
+        $rs = $this->con->select($strReq);
 
         $res = array();
@@ -777,10 +756,8 @@
         }
 
-        $sql = new dcDeleteStatement($this, 'coreSetUserPermissions');
-        $sql
-            ->from($this->prefix . 'permissions')
-            ->where('user_id = ' . $sql->quote($id));
-
-        $this->con->execute($sql->statement());
+        $strReq = 'DELETE FROM ' . $this->prefix . 'permissions ' .
+        "WHERE user_id = '" . $this->con->escape($id) . "' ";
+
+        $this->con->execute($strReq);
 
         foreach ($perms as $blog_id => $p) {
@@ -815,12 +792,9 @@
 
         if ($delete_first || $no_perm) {
-            $sql = new dcDeleteStatement($this, 'coreSetUserBlogPermissions');
-            $sql
-                ->from($this->prefix . 'permissions')
-                ->where(array(
-                    'blog_id = ' . $sql->quote($blog_id),
-                    'user_id = ' . $sql->quote($id)
-                ));
-            $this->con->execute($sql->statement());
+            $strReq = 'DELETE FROM ' . $this->prefix . 'permissions ' .
+            "WHERE blog_id = '" . $this->con->escape($blog_id) . "' " .
+            "AND user_id = '" . $this->con->escape($id) . "' ";
+
+            $this->con->execute($strReq);
         }
 
@@ -840,10 +814,7 @@
         $cur = $this->con->openCursor($this->prefix . 'user');
 
-        $sql = new dcUpdateStatement($this, 'coreSetUserDefaultBlog');
-        $sql->where('user_id = ' . $sql->quote($id));
-
         $cur->user_default_blog = (string) $blog_id;
 
-        $cur->update($sql->whereStatement());
+        $cur->update("WHERE user_id = '" . $this->con->escape($id) . "'");
     }
 
@@ -919,23 +890,21 @@
     public function getBlogPermissions($id, $with_super = true)
     {
-        $sql = new dcSelectStatement($this, 'coreGetBlogPermissions');
-        $sql
-            ->columns(array('U.user_id AS user_id', 'user_super', 'user_name', 'user_firstname', 'user_displayname',
-                'user_email', 'permissions'))
-            ->from($this->prefix . 'user U')
-            ->join('JOIN ' . $this->prefix . 'permissions P ON U.user_id = P.user_id')
-            ->where('blog_id = ' . $sql->quote($id));
+        $strReq =
+        'SELECT U.user_id AS user_id, user_super, user_name, user_firstname, ' .
+        'user_displayname, user_email, permissions ' .
+        'FROM ' . $this->prefix . 'user U ' .
+        'JOIN ' . $this->prefix . 'permissions P ON U.user_id = P.user_id ' .
+        "WHERE blog_id = '" . $this->con->escape($id) . "' ";
 
         if ($with_super) {
-            $sqlSuper = new dcSelectStatement($this, 'coreGetBlogPermissionsSuper');
-            $sqlSuper
-                ->columns(array('U.user_id AS user_id', 'user_super', 'user_name', 'user_firstname', 'user_displayname',
-                    'user_email', 'NULL AS permissions'))
-                ->from($this->prefix . 'user U')
-                ->where('user_super = 1');
-            $sql->sql('UNION ' . $sqlSuper->statement());
-        }
-
-        $rs = $this->con->select($sql->statement());
+            $strReq .=
+            'UNION ' .
+            'SELECT U.user_id AS user_id, user_super, user_name, user_firstname, ' .
+            "user_displayname, user_email, NULL AS permissions " .
+            'FROM ' . $this->prefix . 'user U ' .
+                'WHERE user_super = 1 ';
+        }
+
+        $rs = $this->con->select($strReq);
 
         $res = array();
@@ -986,34 +955,45 @@
     public function getBlogs($params = array(), $count_only = false)
     {
-        $sql = new dcSelectStatement($this, 'coreGetBlogs');
-        $sql->from($this->prefix . 'blog B');
+        $join  = ''; // %1$s
+        $where = ''; // %2$s
 
         if ($count_only) {
-            $sql->columns('COUNT(B.blog_id)');
+            $strReq = 'SELECT count(B.blog_id) ' .
+            'FROM ' . $this->prefix . 'blog B ' .
+                '%1$s ' .
+                'WHERE NULL IS NULL ' .
+                '%2$s ';
         } else {
-            $sql->columns(array('B.blog_id', 'blog_uid', 'blog_url', 'blog_name', 'blog_desc', 'blog_creadt', 'blog_upddt', 'blog_status'));
+            $strReq =
+            'SELECT B.blog_id, blog_uid, blog_url, blog_name, blog_desc, blog_creadt, ' .
+            'blog_upddt, blog_status ' .
+            'FROM ' . $this->prefix . 'blog B ' .
+                '%1$s ' .
+                'WHERE NULL IS NULL ' .
+                '%2$s ';
 
             if (!empty($params['order'])) {
-                $sql->order($sql->escape($params['order']));
+                $strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
             } else {
-                $sql->order('B.blog_id ASC');
+                $strReq .= 'ORDER BY B.blog_id ASC ';
             }
 
             if (!empty($params['limit'])) {
-                $sql->limit($params['limit']);
+                $strReq .= $this->con->limit($params['limit']);
             }
         }
 
         if ($this->auth->userID() && !$this->auth->isSuperAdmin()) {
-            $sql->join('INNER JOIN ' . $this->prefix . 'permissions PE ON B.blog_id = PE.blog_id');
-            $sql->where("AND PE.user_id = " . $sql->quote($this->auth->userID()) .
-                " AND (permissions LIKE '%|usage|%' OR permissions LIKE '%|admin|%' OR permissions LIKE '%|contentadmin|%')" .
-                " AND blog_status IN (1,0)");
+            $join  = 'INNER JOIN ' . $this->prefix . 'permissions PE ON B.blog_id = PE.blog_id ';
+            $where =
+            "AND PE.user_id = '" . $this->con->escape($this->auth->userID()) . "' " .
+                "AND (permissions LIKE '%|usage|%' OR permissions LIKE '%|admin|%' OR permissions LIKE '%|contentadmin|%') " .
+                "AND blog_status IN (1,0) ";
         } elseif (!$this->auth->userID()) {
-            $sql->where('blog_status IN (1,0)');
+            $where = 'AND blog_status IN (1,0) ';
         }
 
         if (isset($params['blog_status']) && $params['blog_status'] !== '' && $this->auth->isSuperAdmin()) {
-            $sql->where('blog_status = ' . (integer) $params['blog_status']);
+            $where .= 'AND blog_status = ' . (integer) $params['blog_status'] . ' ';
         }
 
@@ -1022,17 +1002,19 @@
                 $params['blog_id'] = array($params['blog_id']);
             }
-            $sql->where('B.blog_id ' . $sql->in($params['blog_id']));
+            $where .= 'AND B.blog_id ' . $this->con->in($params['blog_id']);
         }
 
         if (!empty($params['q'])) {
             $params['q'] = strtolower(str_replace('*', '%', $params['q']));
-            $sql->where('(' .
-                "LOWER(B.blog_id) LIKE " . $sql->quote($params['q']) .
-                " OR LOWER(B.blog_name) LIKE " . $sql->quote($params['q']) .
-                " OR LOWER(B.blog_url) LIKE " . $sql->quote($params['q']) .
-                ')');
-        }
-
-        return $this->con->select($sql->statement());
+            $where .=
+            'AND (' .
+            "LOWER(B.blog_id) LIKE '" . $this->con->escape($params['q']) . "' " .
+            "OR LOWER(B.blog_name) LIKE '" . $this->con->escape($params['q']) . "' " .
+            "OR LOWER(B.blog_url) LIKE '" . $this->con->escape($params['q']) . "' " .
+                ') ';
+        }
+
+        $strReq = sprintf($strReq, $join, $where);
+        return $this->con->select($strReq);
     }
 
@@ -1069,7 +1051,5 @@
         $cur->blog_upddt = date('Y-m-d H:i:s');
 
-        $sql = new dcUpdateStatement($this, 'coreUpdBlog');
-        $sql->where('blog_id = ' . $sql->quote($id));
-        $cur->update($sql->whereStatement());
+        $cur->update("WHERE blog_id = '" . $this->con->escape($id) . "'");
     }
 
@@ -1110,10 +1090,8 @@
         }
 
-        $sql = new dcDeleteStatement($this, 'coreDelBlog');
-        $sql
-            ->from($this->prefix . 'blog')
-            ->where('blog_id = ' . $sql->quote($id));
-
-        $this->con->execute($sql->statement());
+        $strReq = 'DELETE FROM ' . $this->prefix . 'blog ' .
+        "WHERE blog_id = '" . $this->con->escape($id) . "' ";
+
+        $this->con->execute($strReq);
     }
 
@@ -1126,11 +1104,9 @@
     public function blogExists($id)
     {
-        $sql = new dcSelectStatement($this, 'coreBlogExists');
-        $sql
-            ->columns('blog_id')
-            ->from($this->prefix . 'blog')
-            ->where('blog_id = ' . $sql->quote($id));
-
-        $rs = $this->con->select($sql->statement());
+        $strReq = 'SELECT blog_id ' .
+        'FROM ' . $this->prefix . 'blog ' .
+        "WHERE blog_id = '" . $this->con->escape($id) . "' ";
+
+        $rs = $this->con->select($strReq);
 
         return !$rs->isEmpty();
@@ -1146,15 +1122,13 @@
     public function countBlogPosts($id, $type = null)
     {
-        $sql = new dcSelectStatement($this, 'coreCountBlogPosts');
-        $sql
-            ->columns('COUNT(post_id)')
-            ->from($this->prefix . 'post')
-            ->where('blog_id = ' . $sql->quote($id));
+        $strReq = 'SELECT COUNT(post_id) ' .
+        'FROM ' . $this->prefix . 'post ' .
+        "WHERE blog_id = '" . $this->con->escape($id) . "' ";
 
         if ($type) {
-            $sql->where('post_type = ' . $sql->quote($type));
-        }
-
-        return $this->con->select($sql->statement())->f(0);
+            $strReq .= "AND post_type = '" . $this->con->escape($type) . "' ";
+        }
+
+        return $this->con->select($strReq)->f(0);
     }
     //@}
@@ -1494,28 +1468,20 @@
     public function indexAllPosts($start = null, $limit = null)
     {
-        $sql = new dcSelectStatement($this, 'coreIndexAllPostsCount');
-        $sql
-            ->columns('COUNT(post_id)')
-            ->from($this->prefix . 'post');
-
-        $rs    = $this->con->select($sql->statement());
+        $strReq = 'SELECT COUNT(post_id) ' .
+        'FROM ' . $this->prefix . 'post';
+        $rs    = $this->con->select($strReq);
         $count = $rs->f(0);
-        unset($sql);
-
-        $sql = new dcSelectStatement($this, 'coreIndexAllPosts');
-        $sql
-            ->columns(array('post_id', 'post_title', 'post_excerpt_xhtml', 'post_content_xhtml'))
-            ->from($this->prefix . 'post');
+
+        $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml ' .
+        'FROM ' . $this->prefix . 'post ';
 
         if ($start !== null && $limit !== null) {
-            $sql->limit($start, $limit);
-        }
-
-        $rs = $this->con->select($sql->statement());
-        unset($sql);
+            $strReq .= $this->con->limit($start, $limit);
+        }
+
+        $rs = $this->con->select($strReq, true);
 
         $cur = $this->con->openCursor($this->prefix . 'post');
 
-        $sql = new dcUpdateStatement($this, 'coreIndexAllPosts');
         while ($rs->fetch()) {
             $words = $rs->post_title . ' ' . $rs->post_excerpt_xhtml . ' ' .
@@ -1523,6 +1489,5 @@
 
             $cur->post_words = implode(' ', text::splitWords($words));
-            $sql->where('post_id = ' . (integer) $rs->post_id, true);
-            $cur->update($sql->whereStatement());
+            $cur->update('WHERE post_id = ' . (integer) $rs->post_id);
             $cur->clean();
         }
@@ -1544,32 +1509,23 @@
     public function indexAllComments($start = null, $limit = null)
     {
-        $sql = new dcSelectStatement($this, 'coreIndexAllCommentsCount');
-        $sql
-            ->columns('COUNT(comment_id)')
-            ->from($this->prefix . 'comment');
-
-        $rs    = $this->con->select($sql->statement());
+        $strReq = 'SELECT COUNT(comment_id) ' .
+        'FROM ' . $this->prefix . 'comment';
+        $rs    = $this->con->select($strReq);
         $count = $rs->f(0);
-        unset($sql);
-
-        $sql = new dcSelectStatement($this, 'coreIndexAllComments');
-        $sql
-            ->columns(array('comment_id', 'comment_content'))
-            ->from($this->prefix . 'comment');
+
+        $strReq = 'SELECT comment_id, comment_content ' .
+        'FROM ' . $this->prefix . 'comment ';
 
         if ($start !== null && $limit !== null) {
-            $sql->limit($start, $limit);
-        }
-
-        $rs = $this->con->select($sql->statement());
-        unset($sql);
+            $strReq .= $this->con->limit($start, $limit);
+        }
+
+        $rs = $this->con->select($strReq);
 
         $cur = $this->con->openCursor($this->prefix . 'comment');
 
-        $sql = new dcUpdateStatement($this, 'coreIndexAllComments');
         while ($rs->fetch()) {
             $cur->comment_words = implode(' ', text::splitWords($rs->comment_content));
-            $sql->where('comment_id = ' . (integer) $rs->comment_id, true);
-            $cur->update($sql->whereStatement());
+            $cur->update('WHERE comment_id = ' . (integer) $rs->comment_id);
             $cur->clean();
         }
@@ -1586,24 +1542,19 @@
     public function countAllComments()
     {
-        $sqlCount = new dcSelectStatement($this, 'coreCountAllComments');
-        $sqlCount
-            ->columns('COUNT(C.comment_id)')
-            ->from($this->prefix . 'comment C')
-            ->where(array(
-                'C.post_id = P.post_id',
-                'C.comment_status = 1'
-            ));
-
-        $sql = new dcUpdateStatement($this, 'coreCountAllComments');
-        $sql
-            ->ref($this->prefix . 'post P');
-
-        $sqlCount->cond('AND C.comment_trackback <> 1', true);
-        $sql->set('nb_comment = (' . $sqlCount->statement() . ')', true);
-        $this->con->execute($sql->statement());
-
-        $sqlCount->cond('AND C.comment_trackback = 1', true);
-        $sql->set('nb_trackback = (' . $sqlCount->statement() . ')', true);
-        $this->con->execute($sql->statement());
+
+        $updCommentReq = 'UPDATE ' . $this->prefix . 'post P ' .
+        'SET nb_comment = (' .
+        'SELECT COUNT(C.comment_id) from ' . $this->prefix . 'comment C ' .
+            'WHERE C.post_id = P.post_id AND C.comment_trackback <> 1 ' .
+            'AND C.comment_status = 1 ' .
+            ')';
+        $updTrackbackReq = 'UPDATE ' . $this->prefix . 'post P ' .
+        'SET nb_trackback = (' .
+        'SELECT COUNT(C.comment_id) from ' . $this->prefix . 'comment C ' .
+            'WHERE C.post_id = P.post_id AND C.comment_trackback = 1 ' .
+            'AND C.comment_status = 1 ' .
+            ')';
+        $this->con->execute($updCommentReq);
+        $this->con->execute($updTrackbackReq);
     }
 
Index: inc/core/class.dc.rs.extensions.php
===================================================================
--- inc/core/class.dc.rs.extensions.php	(revision 3761)
+++ inc/core/class.dc.rs.extensions.php	(revision 3731)
@@ -444,13 +444,13 @@
             return $rs->_nb_media[$rs->index()];
         } else {
-            $sql = new dcSelectStatement($rs->core, 'coreRsExtCountMedia');
-            $sql
-                ->columns(array('count(media_id)'))
-                ->from($rs->core->prefix . 'post_media')
-                ->where('post_id = ' . $sql->quote((integer) $rs->post_id));
+            $strReq =
+            'SELECT count(media_id) ' .
+            'FROM ' . $rs->core->prefix . 'post_media ' .
+            'WHERE post_id = ' . (integer) $rs->post_id . ' ';
             if ($link_type != null) {
-                $sql->where('link_type = ' . $sql->quote($link_type));
+                $strReq .= "AND link_type = '" . $rs->core->con->escape($link_type) . "'";
             }
-            $res                         = (integer) $rs->core->con->select($sql->statement())->f(0);
+
+            $res                         = (integer) $rs->core->con->select($strReq)->f(0);
             $rs->_nb_media[$rs->index()] = $res;
             return $res;
Index: inc/core/class.dc.sql.statement.php
===================================================================
--- inc/core/class.dc.sql.statement.php	(revision 3761)
+++ inc/core/class.dc.sql.statement.php	(revision 3754)
@@ -300,6 +300,6 @@
      * May be used for debugging purpose as:
      *
-     * if (!$sql->isSame($sql->statement(), $strReq)) {
-     *     trigger_error('SQL statement error: ' . $sql->statement() . ' / ' . $strReq, E_USER_ERROR);
+     * if (!$sql->isSame($sql->statement(), $oldRequest)) {
+     *     trigger_error('SQL statement error: ' . $sql->statement() . ' / ' . $oldRequest, E_USER_ERROR);
      * }
      *
