Fixed bug #10099: Use TYPO3_DB->exec_SELECTcountRows() to determine the number of...
authorOliver Hader <oliver.hader@typo3.org>
Mon, 9 Mar 2009 14:12:49 +0000 (14:12 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 9 Mar 2009 14:12:49 +0000 (14:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5162 709f56b5-9817-0410-a4d7-c38de5d9e867

23 files changed:
ChangeLog
t3lib/class.t3lib_admin.php
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_fullsearch.php
t3lib/class.t3lib_install.php
t3lib/class.t3lib_page.php
t3lib/class.t3lib_tcemain.php
t3lib/class.t3lib_treeview.php
typo3/class.db_list.inc
typo3/mod/tools/em/class.em_index.php
typo3/mod/tools/em/class.em_xmlhandler.php
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/cms/layout/db_layout.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_fetce.php
typo3/sysext/cms/web_info/class.tx_cms_webinfo_lang.php
typo3/sysext/indexed_search/class.crawler.php
typo3/sysext/indexed_search/class.indexer.php
typo3/sysext/indexed_search/mod/index.php
typo3/sysext/install/mod/class.tx_install.php
typo3/sysext/tstemplate/ts/index.php

index 3e8a4fa..990a8e0 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-09  Oliver Hader  <oliver@typo3.org>
+
+       * Fixed bug #10099: Use TYPO3_DB->exec_SELECTcountRows() to determine the number of rows 
+
 2009-03-08  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed issue #10635: htmlArea RTE: Two typos in the manual
index 17679e5..5fd1f30 100644 (file)
@@ -386,14 +386,14 @@ class t3lib_admin {
                                        $pid_list_tmp = preg_replace('/^\-1,/','',$pid_list_tmp);
                                }
 
-                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list_tmp.')');
-                               if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($count)) {
-                                       $list[$table]=$row[0];
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $table, 'pid IN ('.$pid_list_tmp.')');
+                               if ($count) {
+                                       $list[$table] = $count;
                                }
 
-                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$pid_list_tmp.')'.t3lib_BEfunc::deleteClause($table));
-                               if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($count)) {
-                                       $list_n[$table]=$row[0];
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $table, 'pid IN ('.$pid_list_tmp.')' . t3lib_BEfunc::deleteClause($table));
+                               if ($count) {
+                                       $list_n[$table] = $count;
                                }
                        }
                }
index 598dcb7..39b7307 100755 (executable)
@@ -3434,34 +3434,27 @@ final class t3lib_BEfunc {
         * @return      string          Output string (or integer count value if no msg string specified)
         */
        public static function referenceCount($table, $ref, $msg = '')  {
-
+                       // Look up the path:
                if ($table=='_FILE') {
-
                        if (t3lib_div::isFirstPartOfStr($ref, PATH_site)) {
                                $ref = substr($ref, strlen(PATH_site));
-                       } else return '';
-
-                               // Look up the path:
-                       list($res) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'count(*) as count',
-                               'sys_refindex',
-                               'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex').
-                                       ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($ref, 'sys_refindex').
-                                       ' AND deleted=0'
-                       );
-
+                               $condition = 'ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($ref, 'sys_refindex');
+                       } else {
+                               return '';
+                       }
                } else {
-                               // Look up the path:
-                       list($res) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'count(*) as count',
-                               'sys_refindex',
-                               'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex').
-                                       ' AND ref_uid='.intval($ref).
-                                       ' AND deleted=0'
-                       );
+                       $condition = 'ref_uid=' . intval($ref);
                }
 
-               return $res['count'] ? ($msg ? sprintf($msg, $res['count']) : $res['count']) : '';
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       '*',
+                       'sys_refindex',
+                       'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
+                               ' AND ' . $condition .
+                               ' AND deleted=0'
+               );
+
+               return ($count ? ($msg ? sprintf($msg, $count) : $count) : '');
        }
 
 
@@ -4042,8 +4035,8 @@ final class t3lib_BEfunc {
                        }
 
                                // Check if sys_refindex is empty
-                       list($count) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(*) as rcount', 'sys_refindex', '1=1');
-                       if (!$count['rcount']) {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
+                       if (!$count) {
                                $url = 'sysext/lowlevel/dbint/index.php?&id=0&SET[function]=refindex';
                                $warnings["backend_reference"] = sprintf(
                                        $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.backend_reference'),
index 19ea9a0..61e3eed 100755 (executable)
@@ -5030,8 +5030,12 @@ final class t3lib_div {
        public static function makeRedirectUrl($inUrl,$l=0,$index_script_url='')        {
                if (strlen($inUrl)>$l)  {
                        $md5 = substr(md5($inUrl),0,20);
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params'));
-                       if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               '*',
+                               'cache_md5params',
+                               'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')
+                       );
+                       if (!$count) {
                                $insertFields = array(
                                        'md5hash' => $md5,
                                        'tstamp' => time(),
index 928a6e2..2f245a1 100755 (executable)
@@ -584,8 +584,7 @@ class t3lib_fullsearch {
                                $qp = $GLOBALS['TYPO3_DB']->searchQuery(array($swords), $list, $table);
 
                                        // Count:
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, $qp.t3lib_BEfunc::deleteClause($table));
-                               list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $table, $qp . t3lib_BEfunc::deleteClause($table));
                                if($count || $showAlways)       {
                                                // Output header:
                                        $out.='<strong>TABLE:</strong> '.$GLOBALS['LANG']->sL($conf['ctrl']['title']).'<BR>';
index b111f89..9ee93cf 100755 (executable)
@@ -729,8 +729,7 @@ class t3lib_install {
                                                                $statements['drop_table'][md5($statement)] = $statement;
                                                        }
                                                                // count:
-                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, '');
-                                                       list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+                                                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $table);
                                                        $statements['tables_count'][md5($statement)] = $count?'Records in table: '.$count:'';
                                                } else {
                                                        $statement = 'CREATE TABLE '.$table." (\n".implode(",\n",$whole_table)."\n)";
index 5063bd3..2cc87f1 100755 (executable)
@@ -464,11 +464,17 @@ class t3lib_pageSelect {
                                                        // If a shortcut mode is set and no valid page is given to select subpags from use the actual page.
                                                $searchUid = intval($row['shortcut'])?intval($row['shortcut']):$row['uid'];
                                        }
-                                       $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', $searchField.'='.$searchUid.$this->where_hid_del.$this->where_groupAccess.' '.$addWhere, '', $sortField);
-                                       if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res2)) {
+                                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                               'uid',
+                                               'pages',
+                                               $searchField . '=' . $searchUid .
+                                                       $this->where_hid_del .
+                                                       $this->where_groupAccess . 
+                                                       ' ' . $addWhere
+                                       );
+                                       if (!$count) {
                                                unset($row);
                                        }
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($res2);
                                } elseif ($row['doktype'] == 4 && $checkShortcuts)      {
                                                // Neither shortcut target nor mode is set. Remove the page from the menu.
                                        unset($row);
index a500021..33abad1 100755 (executable)
@@ -5626,9 +5626,8 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
                $tableList = array();
                foreach (array_keys($GLOBALS['TCA']) as $table) {
                        if (!in_array($table,$allowedArray))    {       // If the table is not in the allowed list, check if there are records...
-                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid='.intval($page_uid));
-                               $count = $GLOBALS['TYPO3_DB']->sql_fetch_row($mres);
-                               if ($count[0])  {
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $table, 'pid=' . intval($page_uid));
+                               if ($count) {
                                        $tableList[]=$table;
                                }
                        }
@@ -6595,8 +6594,14 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
 
                        // Do check:
                if ($prevTitle != $checkTitle || $count<100)    {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid='.intval($pid).' AND '.$field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($checkTitle, $table).$this->deleteClause($table), '', '', '1');
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
+                       $rowCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               'uid',
+                               $table,
+                               'pid=' . intval($pid) .
+                                       ' AND ' . $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($checkTitle, $table) .
+                                       $this->deleteClause($table)
+                       );
+                       if ($rowCount) {
                                return $this->getCopyHeader($table,$pid,$field,$value,$count+1,$checkTitle);
                        }
                }
@@ -6708,9 +6713,12 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
                $inList = trim($this->rmComma(trim($inList)));
                if ($inList && !$this->admin)   {
                        foreach (array_keys($GLOBALS['TCA']) as $table) {
-                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$inList.')'.t3lib_BEfunc::deleteClause($table));
-                               $count = $GLOBALS['TYPO3_DB']->sql_fetch_row($mres);
-                               if ($count[0] && ($this->tableReadOnly($table) || !$this->checkModifyAccessList($table)))       {
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                       'uid',
+                                       $table,
+                                       'pid IN (' . $inList . ')' . t3lib_BEfunc::deleteClause($table)
+                               );
+                               if ($count && ($this->tableReadOnly($table) || !$this->checkModifyAccessList($table))) {
                                        return FALSE;
                                }
                        }
index 0cb95e7..30b5887 100755 (executable)
@@ -860,16 +860,14 @@ class t3lib_treeView {
                        $res = $this->getDataInit($uid);
                        return $this->getDataCount($res);
                } else {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                               'count(*)',
-                                               $this->table,
-                                               $this->parentField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($uid, $this->table).
-                                                       t3lib_BEfunc::deleteClause($this->table).
-                                                       t3lib_BEfunc::versioningPlaceholderClause($this->table).
-                                                       $this->clause   // whereClauseMightContainGroupOrderBy
-                                       );
-                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                       return $row[0];
+                       return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               'uid',
+                               $this->table,
+                               $this->parentField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($uid, $this->table) .
+                                       t3lib_BEfunc::deleteClause($this->table) .
+                                       t3lib_BEfunc::versioningPlaceholderClause($this->table) .
+                                       $this->clause   // whereClauseMightContainGroupOrderBy
+                       );
                }
        }
 
index 7b1c9c5..fd12009 100755 (executable)
@@ -498,13 +498,11 @@ class recordList extends t3lib_recordList {
         * @see makeQueryArray()
         */
        function setTotalItems($queryParts)     {
-               $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                       'count(*)',
-                                       $queryParts['FROM'],
-                                       $queryParts['WHERE']
-                               );
-               list($rCount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
-               $this->totalItems = $rCount;
+               $this->totalItems = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       '*',
+                       $queryParts['FROM'],
+                       $queryParts['WHERE']
+               );
        }
 
        /**
index 7ee74ec..510138d 100644 (file)
@@ -2592,10 +2592,12 @@ EXTENSION KEYS:
                $tablesNA = array();
 
                foreach($tablesArray as $tN)    {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tN, '');
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $tN);
                        if (!$GLOBALS['TYPO3_DB']->sql_error()) {
-                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                               $tables[$tN]='<tr><td>&nbsp;</td><td><a href="'.htmlspecialchars('index.php?CMD[dumpTables]='.rawurlencode($tN).'&CMD[showExt]='.$extKey).'" title="Dump table \''.$tN.'\'">'.$tN.'</a></td><td>&nbsp;&nbsp;&nbsp;</td><td>'.$row[0].' records</td></tr>';
+                               $tables[$tN]= '<tr><td>&nbsp;</td><td><a href="' .
+                                       htmlspecialchars('index.php?CMD[dumpTables]=' . rawurlencode($tN) . '&CMD[showExt]=' . $extKey) .
+                                       '" title="Dump table \'' . $tN . '\'">' . $tN . '</a></td><td>&nbsp;&nbsp;&nbsp;</td><td>' .
+                                       $count . ' records</td></tr>';
                        } else {
                                $tablesNA[$tN]='<tr><td>&nbsp;</td><td>'.$tN.'</td><td>&nbsp;</td><td>Did not exist.</td></tr>';
                        }
index 8b5055e..4314a59 100644 (file)
@@ -123,10 +123,8 @@ class SC_mod_tools_em_xmlhandler {
                }
 
                        // Fetch count
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as cnt', 'cache_extensions', $where);
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-               $this->matchingCount = $row['cnt'];
-               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_extensions', $where);
+               $this->matchingCount = $count;
 
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'cache_extensions', $where, '', $order, $offset.','.$limit);
                $this->extensionsXML = array();
index 195737b..06832eb 100755 (executable)
@@ -1341,10 +1341,9 @@ class tx_cms_layout extends recordList {
                                }
                        }
                } else {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'pages', 'pid='.intval($pid).$qWhere);
-                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                       if ($row[0])    {
-                               $this->plusPages[$pid]=$row[0];
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'pages', 'pid=' . intval($pid) . $qWhere);
+                       if ($count) {
+                               $this->plusPages[$pid] = $count;
                        }
                }
                return $theRows;
@@ -1402,14 +1401,13 @@ class tx_cms_layout extends recordList {
                                                                case 'days':
                                                                        $timespan = mktime (0,0,0)+intval($fParts[1])*3600*24;
                                                                                // Page hits
-                                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                                                                       'count(*)',
-                                                                                                       'sys_stat',
-                                                                                                       $this->stat_select_field.'='.intval($row['uid']).'
-                                                                                                               AND tstamp>='.intval($timespan).'
-                                                                                                               AND tstamp<'.intval($timespan+3600*24)
-                                                                                               );
-                                                                       list($number) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+                                                                       $number = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                                                               '*',
+                                                                               'sys_stat',
+                                                                               $this->stat_select_field . '=' . intval($row['uid']) .
+                                                                                       ' AND tstamp >=' . intval($timespan) .
+                                                                                       ' AND tstamp <' . intval($timespan + 3600 * 24)
+                                                                       );
                                                                        if ($number)    {
                                                                                        // Sessions
                                                                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@@ -2176,16 +2174,16 @@ class tx_cms_layout extends recordList {
         * @return      integer         Number of records.
         */
        function numberOfRecords($table,$pid)   {
-               global $TCA;
-
-               $c=0;
-               if ($TCA[$table])       {
-                       $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($table).t3lib_BEfunc::versioningPlaceholderClause($table));
-                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($result))        {
-                               $c=$row[0];
-                       }
+               if ($GLOBALS['TCA'][$table]) {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               'uid',
+                               $table,
+                               'pid=' . intval($pid) .
+                                       t3lib_BEfunc::deleteClause($table) .
+                                       t3lib_BEfunc::versioningPlaceholderClause($table)
+                       );
                }
-               return $c;
+               return intval($count);
        }
 
        /**
@@ -2456,9 +2454,8 @@ class tx_cms_layout extends recordList {
                if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat'))   {
 
                                // Counting total hits:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_stat', 'page_id='.intval($rec['uid']));
-                       $rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                       if ($rrow[0])   {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid']));
+                       if ($count) {
 
                                        // Get min/max
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id='.intval($rec['uid']));
@@ -2586,8 +2583,13 @@ class tx_cms_layout extends recordList {
                        if ($GLOBALS['BE_USER']->check('tables_select',$tName) && (t3lib_extMgm::isLoaded($tName)||t3lib_div::inList('fe_users,tt_content',$tName) || isset($this->externalTables[$tName])))    {
 
                                        // Make query to count records from page:
-                               $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tName, 'pid='.intval($id).t3lib_BEfunc::deleteClause($tName).t3lib_BEfunc::versioningPlaceholderClause($tName));
-                               list($c) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
+                               $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                       'uid',
+                                       $tName,
+                                       'pid=' . intval($id) .
+                                               t3lib_BEfunc::deleteClause($tName) .
+                                               t3lib_BEfunc::versioningPlaceholderClause($tName)
+                               );
 
                                        // If records were found (or if "tt_content" is the table...):
                                if ($c || t3lib_div::inList('tt_content',$tName))       {
index c3f5e06..237231c 100755 (executable)
@@ -341,8 +341,8 @@ class SC_db_layout {
                }
 
                        // Find if there are ANY languages at all (and if not, remove the language option from function menu).
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'sys_language', ($BE_USER->isAdmin()?'':'hidden=0'));
-               if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  {
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'sys_language', ($BE_USER->isAdmin() ? '' : 'hidden=0'));
+               if (!$count) {
                        unset($this->MOD_MENU['function']['2']);
                }
 
@@ -1257,9 +1257,15 @@ class SC_db_layout {
         * @return      void
         */
        function getNumberOfHiddenElements()    {
-               $q_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_content', 'pid='.intval($this->id).' AND sys_language_uid='.intval($this->current_sys_language).t3lib_BEfunc::BEenableFields('tt_content',1).t3lib_BEfunc::deleteClause('tt_content').t3lib_BEfunc::versioningPlaceholderClause('tt_content'));
-               list($q_count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($q_res);
-               return $q_count;
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'uid',
+                       'tt_content',
+                       'pid=' . intval($this->id) .
+                               ' AND sys_language_uid=' . intval($this->current_sys_language) .
+                               t3lib_BEfunc::BEenableFields('tt_content', 1) .
+                               t3lib_BEfunc::deleteClause('tt_content') .
+                               t3lib_BEfunc::versioningPlaceholderClause('tt_content')
+               );
        }
 
        /**
index 7d1ea97..705a9ce 100755 (executable)
@@ -7264,13 +7264,14 @@ class tslib_cObj {
        function checkPid($uid) {
                $uid = intval($uid);
                if (!isset($this->checkPid_cache[$uid]))        {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($uid).$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')');
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
-                               $this->checkPid_cache[$uid] = 1;
-                       } else {
-                               $this->checkPid_cache[$uid] = 0;
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               'uid',
+                               'pages',
+                               'uid=' . intval($uid) .
+                                       $this->enableFields('pages') .
+                                       ' AND doktype NOT IN (' . $this->checkPid_badDoktypeList . ')'
+                       );
+                       $this->checkPid_cache[$uid] = (bool)$count;
                }
                return $this->checkPid_cache[$uid];
        }
index 300a35b..862ff2d 100755 (executable)
@@ -829,8 +829,8 @@ require_once (PATH_t3lib.'class.t3lib_lock.php');
                                        // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set.
                                        // This does not require the preview flag to be set in the admin panel
                                $idQ = t3lib_div::testInt($this->id) ? 'uid='.intval($this->id) : 'alias='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages').' AND pid>=0';        // pid>=0 added for the sake of versioning...
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0');
-                               if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
+                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'pages', $idQ . ' AND hidden!=0 AND deleted=0');
+                               if ($count) {
                                        $this->fePreview = 1;   // The preview flag is set only if the current page turns out to actually be hidden!
                                        $this->showHiddenPage = 1;
                                }
index 0d220bf..c74081e 100644 (file)
@@ -180,15 +180,16 @@ class tslib_feTCE {
         *
         * @param       string          The database table to check
         * @param       string          The fieldname from the database table to search
-        * @param       string          The value to search for.
+        * @param       integer         The hash value to search for.
         * @return      integer         The number of found rows. If zero then no "double-post" was found and its all OK.
         * @access private
         */
        function checkDoublePostExist($table,$doublePostField,$key)     {
-               $where = $doublePostField.'='.$key;
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, $where);
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-               return $row[0];
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       '*',
+                       $table,
+                       $doublePostField . '=' . $key
+               );
        }
 
        /**
index 4c7de5a..44d5d01 100644 (file)
@@ -399,16 +399,14 @@ class tx_cms_webinfo_lang extends t3lib_extobjbase {
         * @return      integer         Number of content elements from the PID where the language is set to a certain value.
         */
        function getContentElementCount($pageId,$sysLang)       {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'count(*)',
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'uid',
                        'tt_content',
-                       'pid='.intval($pageId).
-                               ' AND sys_language_uid='.intval($sysLang).
-                               t3lib_BEfunc::deleteClause('tt_content').
+                       'pid=' . intval($pageId) .
+                               ' AND sys_language_uid=' . intval($sysLang) .
+                               t3lib_BEfunc::deleteClause('tt_content') .
                                t3lib_BEfunc::versioningPlaceholderClause('tt_content')
                );
-
-               list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
                return $count ? $count : '-';
        }
 }
index 5a92c44..ba6e142 100755 (executable)
@@ -524,13 +524,13 @@ class tx_indexedsearch_crawler {
                foreach($runningIndexingConfigurations as $cfgRec)      {
 
                                // Look for ended processes:
-                       list($queued_items) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'count(*) AS count',
+                       $queued_items = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               '*',
                                'tx_crawler_queue',
-                               'set_id='.intval($cfgRec['set_id']).' AND exec_time=0'
+                               'set_id=' . intval($cfgRec['set_id']) . ' AND exec_time=0'
                        );
 
-                       if (!$queued_items['count'])    {
+                       if (!$queued_items) {
 
                                        // Lookup old phash rows:
                                $oldPhashRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
index a17a7e3..aba51bd 100755 (executable)
@@ -1560,8 +1560,14 @@ class tx_indexedsearch_indexer {
         */
        function submitFile_grlist($hash)       {
                        // Testing if there is a gr_list record for a non-logged in user and if so, there is no need to place another one.
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash', 'index_grlist', 'phash='.intval($hash).' AND (hash_gr_list='.$this->md5inthash($this->defaultGrList).' OR hash_gr_list='.$this->md5inthash($this->conf['gr_list']).')');
-               if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  {
+               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'phash',
+                       'index_grlist',
+                       'phash=' . intval($hash) .
+                               ' AND (hash_gr_list=' . $this->md5inthash($this->defaultGrList) .
+                               ' OR hash_gr_list=' . $this->md5inthash($this->conf['gr_list']) . ')'
+               );
+               if (!$count) {
                        $this->submit_grlist($hash,$hash);
                }
        }
@@ -1690,8 +1696,11 @@ class tx_indexedsearch_indexer {
         * @return      void
         */
        function is_grlist_set($phash_x)        {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('phash_x', 'index_grlist', 'phash_x='.intval($phash_x));
-               return $GLOBALS['TYPO3_DB']->sql_num_rows($res);
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'phash_x',
+                       'index_grlist',
+                       'phash_x=' . intval($phash_x)
+               );
        }
 
        /**
index 68e2fe4..998f739 100755 (executable)
@@ -236,9 +236,10 @@ class SC_mod_tools_isearch_index {
                $recList=array();
                reset($tables);
                while(list(,$t)=each($tables))  {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
-                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                       $recList[] = array($this->tableHead($t), $row[0]);
+                       $recList[] = array(
+                               $this->tableHead($t),
+                               $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $t)
+                       );
                }
                return $recList;
        }
@@ -270,9 +271,10 @@ class SC_mod_tools_isearch_index {
                $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
 
                        // TYPO3 pages:
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-               $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
+               $recList[] = array(
+                       $this->tableHead("TYPO3 pages, raw"),
+                       $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_phash', 'data_page_id!=0')
+               );
 
                        // External files, unique
                $items = array();
@@ -281,9 +283,10 @@ class SC_mod_tools_isearch_index {
                $recList[] = array($this->tableHead("External files"), $row[0]);
 
                        // External files
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-               $recList[] = array($this->tableHead("External files, raw"), $row[0]);
+               $recList[] = array(
+                       $this->tableHead("External files, raw"),
+                       $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_phash', 'data_filename!=\'\'')
+               );
 
                return $recList;
        }
@@ -463,9 +466,7 @@ class SC_mod_tools_isearch_index {
         * @return      [type]          ...
         */
        function getNumberOfSections($phash)    {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-               return $row[0];
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_section', 'phash=' . intval($phash));
        }
 
        /**
@@ -503,9 +504,7 @@ class SC_mod_tools_isearch_index {
         * @return      [type]          ...
         */
        function getNumberOfFulltext($phash)    {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-               return $row[0];
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_fulltext', 'phash=' . intval($phash));
        }
 
        /**
index 419bbd7..08dc4e0 100755 (executable)
@@ -1268,9 +1268,7 @@ From sub-directory:
                        // Get cache_imagesizes info
                if (isset ($tables['cache_imagesizes'])) {
                        $cleanupType['cache_imagesizes'] = 'Clear cached image sizes only';
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(*) AS icount', 'cache_imagesizes', '');
-                       $resArr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc ($res);
-                       $cachedImageSizesCounter = intval ($resArr['icount']);
+                       $cachedImageSizesCounter = intval($GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_imagesizes'));
                } else {
                        $this->message($headCode,'Table cache_imagesizes does not exist!',"
                                The table cache_imagesizes was not found. Please check your database settings in Basic Configuration and compare your table definition with the Database Analyzer.
@@ -3340,8 +3338,7 @@ From sub-directory:
 
                        // Getting number of static_template records
                if ($whichTables['static_template'])    {
-                       $res_static = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', '');
-                       list($static_template_count) = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_static);
+                       $static_template_count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'static_template');
                }
                $static_template_count=intval($static_template_count);
 
@@ -3681,8 +3678,12 @@ From sub-directory:
                                                                $username = 'admin';
                                                                $pass = 'password';
 
-                                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'be_users', 'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr($username, 'be_users'));
-                                                               if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  {
+                                                               $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                                                       'uid',
+                                                                       'be_users',
+                                                                       'username=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($username, 'be_users')
+                                                               );
+                                                               if (!$count) {
                                                                        $insertFields = array(
                                                                                'username' => $username,
                                                                                'password' => md5($pass),
@@ -3921,8 +3922,7 @@ From sub-directory:
                                                if ($table!='--div--')  {
                                                        $table_c = TYPO3_OS=='WIN' ? strtolower($table) : $table;
                                                        if ($whichTables[$table_c])     {
-                                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, '');
-                                                               list($countEntries[$table]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+                                                               $countEntries[$table] = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $table);
                                                                        // Checkboxes:
                                                                $checkBoxes[]= '<input type="checkbox" name="TYPO3_INSTALL[database_clearcache]['.$table.']" id="TYPO3_INSTALL[database_clearcache]['.$table.']" value="1"'.($this->INSTALL['database_clearcache'][$table]||$_GET['PRESET']['database_clearcache'][$table]?' checked="checked"':'').'> <label for="TYPO3_INSTALL[database_clearcache]['.$table.']"><strong>'.$table.'</strong> ('.$countEntries[$table].' rows) - '.$labelArr[$table].'</label>';
                                                        }
@@ -4101,9 +4101,7 @@ From sub-directory:
         * @return      [type]          ...
         */
        function isBackendAdminUser()   {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'be_users', 'admin=1');
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-               return current($row);
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'be_users', 'admin=1');
        }
 
        /**
@@ -4112,9 +4110,7 @@ From sub-directory:
         * @return      [type]          ...
         */
        function isStaticTemplates()    {
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', '');
-               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-               return current($row);
+               return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'static_template');
        }
 
        /**
index 005d654..77584b7 100644 (file)
@@ -323,26 +323,9 @@ class SC_mod_web_ts_index extends t3lib_SCbase {
        function getCountCacheTables($humanReadable) {
                $out = array();
 
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'count(id)',
-                       'cache_pages',
-                       ''
-               );
-               list($out['cache_pages']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'count(id)',
-                       'cache_pagesection',
-                       ''
-               );
-               list($out['cache_pagesection']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'count(id)',
-                       'cache_hash',
-                       ''
-               );
-               list($out['cache_hash']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+               $out['cache_pages'] = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('id', 'cache_pages');
+               $out['cache_pagesection'] = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('id', 'cache_pagesection');
+               $out['cache_hash'] = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('id', 'cache_hash');
 
                if ($humanReadable) {
                        $newOut = array();