Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_sqlengine
authorSteffen Kamper <info@sk-typo3.de>
Wed, 24 Nov 2010 14:22:38 +0000 (14:22 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 24 Nov 2010 14:22:38 +0000 (14:22 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9569 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_sqlengine.php

index 1027fe3..5046e6d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-11-24  Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_sqlengine
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_spritemanager
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_softrefproc
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_scbase
index ea2d6f3..6da76bf 100644 (file)
@@ -1,29 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2004-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+ *  Copyright notice
+ *
+ *  (c) 2004-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * PHP SQL engine
  * EXPERIMENTAL!
  *
  *
  *  104: class t3lib_sqlengine extends t3lib_sqlparser
- *  126:     function init($config, &$pObj)
- *  134:     function resetStatusVars()
- *  150:     function processAccordingToConfig(&$value,$fInfo)
+ *  126:        function init($config, &$pObj)
+ *  134:        function resetStatusVars()
+ *  150:        function processAccordingToConfig(&$value,$fInfo)
  *
- *              SECTION: SQL queries
- *  205:     function exec_INSERTquery($table,$fields_values)
- *  273:     function exec_UPDATEquery($table,$where,$fields_values)
- *  332:     function exec_DELETEquery($table,$where)
- *  383:     function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)
- *  426:     function sql_query($query)
- *  437:     function sql_error()
- *  446:     function sql_insert_id()
- *  455:     function sql_affected_rows()
- *  465:     function quoteStr($str)
+ *                       SECTION: SQL queries
+ *  205:        function exec_INSERTquery($table,$fields_values)
+ *  273:        function exec_UPDATEquery($table,$where,$fields_values)
+ *  332:        function exec_DELETEquery($table,$where)
+ *  383:        function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)
+ *  426:        function sql_query($query)
+ *  437:        function sql_error()
+ *  446:        function sql_insert_id()
+ *  455:        function sql_affected_rows()
+ *  465:        function quoteStr($str)
  *
- *              SECTION: SQL admin functions
- *  490:     function admin_get_tables()
- *  501:     function admin_get_fields($tableName)
- *  512:     function admin_get_keys($tableName)
- *  523:     function admin_query($query)
+ *                       SECTION: SQL admin functions
+ *  490:        function admin_get_tables()
+ *  501:        function admin_get_fields($tableName)
+ *  512:        function admin_get_keys($tableName)
+ *  523:        function admin_query($query)
  *
- *              SECTION: Data Source I/O
- *  548:     function readDataSource($table)
- *  560:     function saveDataSource($table)
+ *                       SECTION: Data Source I/O
+ *  548:        function readDataSource($table)
+ *  560:        function saveDataSource($table)
  *
- *              SECTION: SQL engine functions (PHP simulation of SQL) - still experimental
- *  590:     function selectFromData($table,$where)
- *  628:     function select_evalSingle($table,$config,&$itemKeys)
- *  747:     function getResultSet($keys, $table, $fieldList)
+ *                       SECTION: SQL engine functions (PHP simulation of SQL) - still experimental
+ *  590:        function selectFromData($table,$where)
+ *  628:        function select_evalSingle($table,$config,&$itemKeys)
+ *  747:        function getResultSet($keys, $table, $fieldList)
  *
- *              SECTION: Debugging
- *  790:     function debug_printResultSet($array)
+ *                       SECTION: Debugging
+ *  790:        function debug_printResultSet($array)
  *
  *
  *  829: class t3lib_sqlengine_resultobj
- *  843:     function sql_num_rows()
- *  852:     function sql_fetch_assoc()
- *  863:     function sql_fetch_row()
- *  881:     function sql_data_seek($pointer)
- *  894:     function sql_field_type()
+ *  843:        function sql_num_rows()
+ *  852:        function sql_fetch_assoc()
+ *  863:        function sql_fetch_row()
+ *  881:        function sql_data_seek($pointer)
+ *  894:        function sql_field_type()
  *
  * TOTAL FUNCTIONS: 27
  * (This index is automatically created/updated by the extension "extdeveval")
  */
 
 
-
-
-
-
-
-
 /**
  * PHP SQL engine / server
  * Basically this is trying to emulation SQL record selection by PHP, thus allowing SQL queries into alternative data storages managed by PHP.
 class t3lib_sqlengine extends t3lib_sqlparser {
 
                // array with data records: [table name][num.index] = records
-       var $data = array();                                            // Data source storage
+       var $data = array(); // Data source storage
 
 
                // Internal, SQL Status vars:
-       var $errorStatus = '';                                          // Set with error message of last operation
-       var $lastInsertedId = 0;                                        // Set with last inserted unique ID
-       var $lastAffectedRows = 0;                                      // Set with last number of affected rows.
-
+       var $errorStatus = ''; // Set with error message of last operation
+       var $lastInsertedId = 0; // Set with last inserted unique ID
+       var $lastAffectedRows = 0; // Set with last number of affected rows.
 
 
        /**
@@ -137,7 +130,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         *
         * @return      void
         */
-       function resetStatusVars()      {
+       function resetStatusVars() {
                $this->errorStatus = '';
                $this->lastInsertedId = 0;
                $this->lastAffectedRows = 0;
@@ -153,47 +146,42 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       array           $fInfo Field configuration data
         * @return      mixed           The processed input value
         */
-       function processAccordingToConfig(&$value,$fInfo)       {
+       function processAccordingToConfig(&$value, $fInfo) {
                $options = $this->parseFieldDef($fInfo['Type']);
 
-               switch(strtolower($options['fieldType']))       {
+               switch (strtolower($options['fieldType'])) {
                        case 'int':
                        case 'smallint':
                        case 'tinyint':
                        case 'mediumint':
                                $value = intval($value);
-                               if ($options['featureIndex']['UNSIGNED'])       {
-                                       $value = t3lib_div::intInRange($value,0);
+                               if ($options['featureIndex']['UNSIGNED']) {
+                                       $value = t3lib_div::intInRange($value, 0);
                                }
                        break;
                        case 'double':
-                               $value = (double)$value;
+                               $value = (double) $value;
                        break;
                        case 'varchar':
                        case 'char':
-                               $value = substr($value,0,trim($options['value']));
+                               $value = substr($value, 0, trim($options['value']));
                        break;
                        case 'text':
                        case 'blob':
-                               $value = substr($value,0,65536);
+                               $value = substr($value, 0, 65536);
                        break;
                        case 'tinytext':
                        case 'tinyblob':
-                               $value = substr($value,0,256);
+                               $value = substr($value, 0, 256);
                        break;
                        case 'mediumtext':
                        case 'mediumblob':
-                               // ??
+                                       // ??
                        break;
                }
        }
 
 
-
-
-
-
-
        /********************************
         *
         * SQL queries
@@ -208,7 +196,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       array           Field values as key=>value pairs.
         * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
         */
-       function exec_INSERTquery($table,$fields_values)        {
+       function exec_INSERTquery($table, $fields_values) {
 
                        // Initialize
                $this->resetStatusVars();
@@ -217,38 +205,40 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                $this->readDataSource($table);
 
                        // If data source is set:
-               if (is_array($this->data[$table]))      {
+               if (is_array($this->data[$table])) {
 
-                       $fieldInformation = $this->admin_get_fields($table);            // Should cache this...!
+                       $fieldInformation = $this->admin_get_fields($table); // Should cache this...!
 
                                // Looking for unique keys:
                        $saveArray = array();
-                       foreach($fieldInformation as $fInfo)    {
+                       foreach ($fieldInformation as $fInfo) {
 
                                        // Field name:
                                $fN = $fInfo['Field'];
 
                                        // Set value:
-// FIXME $options not defined
+                                       // FIXME $options not defined
                                $saveArray[$fN] = isset($fields_values[$fN]) ? $fields_values[$fN] : $options['Default'];
 
                                        // Process value:
                                $this->processAccordingToConfig($saveArray[$fN], $fInfo);
 
                                        // If an auto increment field is found, find the largest current uid:
-                               if ($fInfo['Extra'] == 'auto_increment')        {
+                               if ($fInfo['Extra'] == 'auto_increment') {
 
                                                // Get all UIDs:
                                        $uidArray = array();
-                                       foreach($this->data[$table] as $r)      {
+                                       foreach ($this->data[$table] as $r) {
                                                $uidArray[] = $r[$fN];
                                        }
 
                                                // If current value is blank or already in array, we create a new:
-                                       if (!$saveArray[$fN] || in_array(intval($saveArray[$fN]), $uidArray))   {
-                                               if (count($uidArray))   {
-                                                       $saveArray[$fN] = max($uidArray)+1;
-                                               } else $saveArray[$fN] = 1;
+                                       if (!$saveArray[$fN] || in_array(intval($saveArray[$fN]), $uidArray)) {
+                                               if (count($uidArray)) {
+                                                       $saveArray[$fN] = max($uidArray) + 1;
+                                               } else {
+                                                       $saveArray[$fN] = 1;
+                                               }
                                        }
 
                                                // Update "last inserted id":
@@ -263,7 +253,9 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                        $this->saveDataSource($table);
 
                        return TRUE;
-               } else $this->errorStatus = 'No data loaded.';
+               } else {
+                       $this->errorStatus = 'No data loaded.';
+               }
 
                return FALSE;
        }
@@ -276,7 +268,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       array           Field values as key=>value pairs.
         * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
         */
-       function exec_UPDATEquery($table,$where,$fields_values) {
+       function exec_UPDATEquery($table, $where, $fields_values) {
 
                        // Initialize:
                $this->resetStatusVars();
@@ -285,45 +277,49 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                $this->readDataSource($table);
 
                        // If anything is there:
-               if (is_array($this->data[$table]))      {
+               if (is_array($this->data[$table])) {
 
                                // Parse WHERE clause:
                        $where = $this->parseWhereClause($where);
 
-                       if (is_array($where))   {
+                       if (is_array($where)) {
 
                                        // Field information
-                               $fieldInformation = $this->admin_get_fields($table);            // Should cache this...!
+                               $fieldInformation = $this->admin_get_fields($table); // Should cache this...!
 
                                        // Traverse fields to update:
-                               foreach($fields_values as $fName => $fValue)    {
-                                       $this->processAccordingToConfig($fields_values[$fName],$fieldInformation[$fName]);
+                               foreach ($fields_values as $fName => $fValue) {
+                                       $this->processAccordingToConfig($fields_values[$fName], $fieldInformation[$fName]);
                                }
 
                                        // Do query, returns array with keys to the data array of the result:
-                               $itemKeys = $this->selectFromData($table,$where);
+                               $itemKeys = $this->selectFromData($table, $where);
 
                                        // Set "last affected rows":
                                $this->lastAffectedRows = count($itemKeys);
 
                                        // Update rows:
-                               if ($this->lastAffectedRows)    {
+                               if ($this->lastAffectedRows) {
                                                // Traverse result set here:
-                                       foreach($itemKeys as $dataArrayKey)     {
+                                       foreach ($itemKeys as $dataArrayKey) {
 
                                                        // Traverse fields to update:
-                                               foreach($fields_values as $fName => $fValue)    {
+                                               foreach ($fields_values as $fName => $fValue) {
                                                        $this->data[$table][$dataArrayKey][$fName] = $fValue;
                                                }
                                        }
 
-                                       // Save data source
+                                               // Save data source
                                        $this->saveDataSource($table);
                                }
 
                                return TRUE;
-                       } else $this->errorStatus = 'WHERE clause contained errors: '.$where;
-               } else $this->errorStatus = 'No data loaded.';
+                       } else {
+                               $this->errorStatus = 'WHERE clause contained errors: ' . $where;
+                       }
+               } else {
+                       $this->errorStatus = 'No data loaded.';
+               }
 
                return FALSE;
        }
@@ -335,7 +331,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          WHERE clause
         * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
         */
-       function exec_DELETEquery($table,$where)        {
+       function exec_DELETEquery($table, $where) {
 
                        // Initialize:
                $this->resetStatusVars();
@@ -344,23 +340,23 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                $this->readDataSource($table);
 
                        // If anything is there:
-               if (is_array($this->data[$table]))      {
+               if (is_array($this->data[$table])) {
 
                                // Parse WHERE clause:
                        $where = $this->parseWhereClause($where);
 
-                       if (is_array($where))   {
+                       if (is_array($where)) {
 
                                        // Do query, returns array with keys to the data array of the result:
-                               $itemKeys = $this->selectFromData($table,$where);
+                               $itemKeys = $this->selectFromData($table, $where);
 
                                        // Set "last affected rows":
                                $this->lastAffectedRows = count($itemKeys);
 
                                        // Remove rows:
-                               if ($this->lastAffectedRows)    {
+                               if ($this->lastAffectedRows) {
                                                // Traverse result set:
-                                       foreach($itemKeys as $dataArrayKey)     {
+                                       foreach ($itemKeys as $dataArrayKey) {
                                                unset($this->data[$table][$dataArrayKey]);
                                        }
 
@@ -369,8 +365,12 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                                }
 
                                return TRUE;
-                       } else $this->errorStatus = 'WHERE clause contained errors: '.$where;
-               } else $this->errorStatus = 'No data loaded.';
+                       } else {
+                               $this->errorStatus = 'WHERE clause contained errors: ' . $where;
+                       }
+               } else {
+                       $this->errorStatus = 'No data loaded.';
+               }
 
                return FALSE;
        }
@@ -386,14 +386,14 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Optional LIMIT value ([begin,]max), if none, supply blank string.
         * @return      object          Returns result object, but if errors, returns false
         */
-       function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)    {
+       function exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit) {
 
                        // Initialize:
                $this->resetStatusVars();
 
                        // Create result object
                $sqlObj = t3lib_div::makeInstance('t3lib_sqlengine_resultobj');
-               $sqlObj->result = array();      // Empty result as a beginning
+               $sqlObj->result = array(); // Empty result as a beginning
 
                        // Get table list:
                $tableArray = $this->parseFromTables($from_table);
@@ -403,22 +403,26 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                $this->readDataSource($table);
 
                        // If anything is there:
-               if (is_array($this->data[$table]))      {
+               if (is_array($this->data[$table])) {
 
                                // Parse WHERE clause:
                        $where = $this->parseWhereClause($where_clause);
-                       if (is_array($where))   {
+                       if (is_array($where)) {
 
                                        // Do query, returns array with keys to the data array of the result:
-                               $itemKeys = $this->selectFromData($table,$where);
+                               $itemKeys = $this->selectFromData($table, $where);
 
                                        // Finally, read the result rows into this variable:
-                               $sqlObj->result = $this->getResultSet($itemKeys,$table,'*');
+                               $sqlObj->result = $this->getResultSet($itemKeys, $table, '*');
                                        // Reset and return result:
                                reset($sqlObj->result);
                                return $sqlObj;
-                       } else $this->errorStatus = 'WHERE clause contained errors: '.$where;
-               }  else $this->errorStatus = 'No data loaded: '.$this->errorStatus;
+                       } else {
+                               $this->errorStatus = 'WHERE clause contained errors: ' . $where;
+                       }
+               } else {
+                       $this->errorStatus = 'No data loaded: ' . $this->errorStatus;
+               }
 
                return FALSE;
        }
@@ -429,7 +433,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Query to execute
         * @return      object          Result object or false if error
         */
-       function sql_query($query)      {
+       function sql_query($query) {
                $res = t3lib_div::makeInstance('t3lib_sqlengine_resultobj');
                $res->result = array();
                return $res;
@@ -440,7 +444,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         *
         * @return      string          Error message, if any
         */
-       function sql_error()    {
+       function sql_error() {
                return $this->errorStatus;
        }
 
@@ -468,19 +472,11 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Input String
         * @return      string          String, with quotes escaped
         */
-       function quoteStr($str) {
+       function quoteStr($str) {
                return addslashes($str);
        }
 
 
-
-
-
-
-
-
-
-
        /**************************************
         *
         * SQL admin functions
@@ -494,7 +490,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @return      array           Tables in an array (tablename is in both key and value)
         * @todo        Should return table details in value! see t3lib_db::admin_get_tables()
         */
-       function admin_get_tables()     {
+       function admin_get_tables() {
                $whichTables = array();
                return $whichTables;
        }
@@ -505,7 +501,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Table name
         * @return      array           Field information in an associative array with fieldname => field row
         */
-       function admin_get_fields($tableName)   {
+       function admin_get_fields($tableName) {
                $output = array();
                return $output;
        }
@@ -516,7 +512,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Table name
         * @return      array           Key information in a numeric array
         */
-       function admin_get_keys($tableName)     {
+       function admin_get_keys($tableName) {
                $output = array();
                return $output;
        }
@@ -527,17 +523,11 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Query to execute
         * @return      pointer         Result pointer
         */
-       function admin_query($query)    {
+       function admin_query($query) {
                return $this->sql_query($query);
        }
 
 
-
-
-
-
-
-
        /********************************
         *
         * Data Source I/O
@@ -552,7 +542,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @return      void
         * @todo        Table locking tools?
         */
-       function readDataSource($table) {
+       function readDataSource($table) {
                $this->data[$table] = array();
        }
 
@@ -564,22 +554,11 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @return      void
         * @todo        Table locking tools?
         */
-       function saveDataSource($table) {
+       function saveDataSource($table) {
                debug($this->data[$table]);
        }
 
 
-
-
-
-
-
-
-
-
-
-
-
        /********************************
         *
         * SQL engine functions (PHP simulation of SQL) - still experimental
@@ -594,26 +573,29 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       array           Where clause parsed into array
         * @return      array           Array of keys pointing to result rows in $this->data[$table]
         */
-       function selectFromData($table,$where)  {
+       function selectFromData($table, $where) {
 
                $output = array();
-               if (is_array($this->data[$table]))      {
+               if (is_array($this->data[$table])) {
 
                                // All keys:
                        $OR_index = 0;
+                       $itemKeys = array();
 
-                       foreach($where as $config)      {
+                       foreach ($where as $config) {
 
-                               if (strtoupper($config['operator'])=='OR')      {
+                               if (strtoupper($config['operator']) == 'OR') {
                                        $OR_index++;
                                }
 
-                               if (!isset($itemKeys[$OR_index]))       $itemKeys[$OR_index] = array_keys($this->data[$table]);
+                               if (!isset($itemKeys[$OR_index])) {
+                                       $itemKeys[$OR_index] = array_keys($this->data[$table]);
+                               }
 
-                               $this->select_evalSingle($table,$config,$itemKeys[$OR_index]);
+                               $this->select_evalSingle($table, $config, $itemKeys[$OR_index]);
                        }
 
-                       foreach($itemKeys as $uidKeys)  {
+                       foreach ($itemKeys as $uidKeys) {
                                $output = array_merge($output, $uidKeys);
                        }
                        $output = array_unique($output);
@@ -632,14 +614,14 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @return      void            Data array passed by reference
         * @see selectFromData()
         */
-       function select_evalSingle($table,$config,&$itemKeys)   {
-               $neg = preg_match('/^AND[[:space:]]+NOT$/',trim($config['operator']));
-
-               if (is_array($config['sub']))   {
-                       $subSelKeys = $this->selectFromData($table,$config['sub']);
-                       if ($neg)       {
-                               foreach($itemKeys as $kk => $vv)        {
-                                       if (in_array($vv,$subSelKeys))  {
+       function select_evalSingle($table, $config, &$itemKeys) {
+               $neg = preg_match('/^AND[[:space:]]+NOT$/', trim($config['operator']));
+
+               if (is_array($config['sub'])) {
+                       $subSelKeys = $this->selectFromData($table, $config['sub']);
+                       if ($neg) {
+                               foreach ($itemKeys as $kk => $vv) {
+                                       if (in_array($vv, $subSelKeys)) {
                                                unset($itemKeys[$kk]);
                                        }
                                }
@@ -647,40 +629,40 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                                $itemKeys = array_intersect($itemKeys, $subSelKeys);
                        }
                } else {
-                       $comp = strtoupper(str_replace(array(' ',TAB,CR,LF),'',$config['comparator']));
+                       $comp = strtoupper(str_replace(array(' ', TAB, CR, LF), '', $config['comparator']));
                        $mod = strtoupper($config['modifier']);
-                       switch($comp)   {
+                       switch ($comp) {
                                case 'NOTLIKE':
                                case 'LIKE':
                                        $like_value = strtolower($config['value'][0]);
-                                       if (substr($like_value,0,1)=='%')       {
+                                       if (substr($like_value, 0, 1) == '%') {
                                                $wildCard_begin = TRUE;
-                                               $like_value = substr($like_value,1);
+                                               $like_value = substr($like_value, 1);
                                        }
-                                       if (substr($like_value,-1)=='%')        {
+                                       if (substr($like_value, -1) == '%') {
                                                $wildCard_end = TRUE;
-                                               $like_value = substr($like_value,0,-1);
+                                               $like_value = substr($like_value, 0, -1);
                                        }
                                break;
                                case 'NOTIN':
                                case 'IN':
                                        $in_valueArray = array();
-                                       foreach($config['value'] as $vParts)    {
-                                               $in_valueArray[] = (string)$vParts[0];
+                                       foreach ($config['value'] as $vParts) {
+                                               $in_valueArray[] = (string) $vParts[0];
                                        }
                                break;
                        }
 
-                       foreach($itemKeys as $kk => $v) {
+                       foreach ($itemKeys as $kk => $v) {
                                $field_value = $this->data[$table][$v][$config['field']];
 
                                        // Calculate it:
-                               if ($config['calc']=='&')       {
-                                       $field_value&=intval($config['calc_value']);
+                               if ($config['calc'] == '&') {
+                                       $field_value &= intval($config['calc_value']);
                                }
 
                                        // Compare it:
-                               switch($comp)   {
+                               switch ($comp) {
                                        case '<=':
                                                $bool = $field_value <= $config['value'][0];
                                        break;
@@ -694,30 +676,34 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                                                $bool = $field_value > $config['value'][0];
                                        break;
                                        case '=':
-                                               $bool = !strcmp($field_value,$config['value'][0]);
+                                               $bool = !strcmp($field_value, $config['value'][0]);
                                        break;
                                        case '!=':
-                                               $bool = strcmp($field_value,$config['value'][0]);
+                                               $bool = strcmp($field_value, $config['value'][0]);
                                        break;
                                        case 'NOTIN':
                                        case 'IN':
-                                               $bool = in_array((string)$field_value, $in_valueArray);
-                                               if ($comp=='NOTIN')     $bool = !$bool;
+                                               $bool = in_array((string) $field_value, $in_valueArray);
+                                               if ($comp == 'NOTIN') {
+                                                       $bool = !$bool;
+                                               }
                                        break;
                                        case 'NOTLIKE':
                                        case 'LIKE':
-                                               if (!strlen($like_value))       {
+                                               if (!strlen($like_value)) {
                                                        $bool = TRUE;
-                                               } elseif ($wildCard_begin && !$wildCard_end)    {
-                                                       $bool = !strcmp(substr(strtolower($field_value),-strlen($like_value)),$like_value);
-                                               } elseif (!$wildCard_begin && $wildCard_end)    {
-                                                       $bool = !strcmp(substr(strtolower($field_value),0,strlen($like_value)),$like_value);
-                                               } elseif ($wildCard_begin && $wildCard_end)     {
-                                                       $bool = strstr($field_value,$like_value);
+                                               } elseif ($wildCard_begin && !$wildCard_end) {
+                                                       $bool = !strcmp(substr(strtolower($field_value), -strlen($like_value)), $like_value);
+                                               } elseif (!$wildCard_begin && $wildCard_end) {
+                                                       $bool = !strcmp(substr(strtolower($field_value), 0, strlen($like_value)), $like_value);
+                                               } elseif ($wildCard_begin && $wildCard_end) {
+                                                       $bool = strstr($field_value, $like_value);
                                                } else {
-                                                       $bool = !strcmp(strtolower($field_value),$like_value);
+                                                       $bool = !strcmp(strtolower($field_value), $like_value);
+                                               }
+                                               if ($comp == 'NOTLIKE') {
+                                                       $bool = !$bool;
                                                }
-                                               if ($comp=='NOTLIKE')   $bool = !$bool;
                                        break;
                                        default:
                                                $bool = $field_value ? TRUE : FALSE;
@@ -725,10 +711,12 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                                }
 
                                        // General negation:
-                               if ($neg)       $bool = !$bool;
+                               if ($neg) {
+                                       $bool = !$bool;
+                               }
 
                                        // Modify?
-                               switch($mod)    {
+                               switch ($mod) {
                                        case 'NOT':
                                        case '!':
                                                $bool = !$bool;
@@ -736,7 +724,7 @@ class t3lib_sqlengine extends t3lib_sqlparser {
                                }
 
                                        // Action:
-                               if (!$bool)     {
+                               if (!$bool) {
                                        unset($itemKeys[$kk]);
                                }
                        }
@@ -751,15 +739,15 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       string          Fieldlist (commaseparated)
         * @return      array           Result array with "rows"
         */
-       function getResultSet($keys, $table, $fieldList)        {
-               $fields = t3lib_div::trimExplode(',',$fieldList);
+       function getResultSet($keys, $table, $fieldList) {
+               $fields = t3lib_div::trimExplode(',', $fieldList);
 
                $output = array();
-               foreach($keys as $kValue)       {
-                       if ($fieldList=='*')    {
+               foreach ($keys as $kValue) {
+                       if ($fieldList == '*') {
                                $output[$kValue] = $this->data[$table][$kValue];
                        } else {
-                               foreach($fields as $fieldName)  {
+                               foreach ($fields as $fieldName) {
                                        $output[$kValue][$fieldName] = $this->data[$table][$kValue][$fieldName];
                                }
                        }
@@ -769,19 +757,6 @@ class t3lib_sqlengine extends t3lib_sqlparser {
        }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
        /*************************
         *
         * Debugging
@@ -794,34 +769,36 @@ class t3lib_sqlengine extends t3lib_sqlparser {
         * @param       array           Result set array (array of rows)
         * @return      string          HTML table
         */
-       function debug_printResultSet($array)   {
+       function debug_printResultSet($array) {
 
-               if (count($array))      {
-                       $tRows=array();
+               if (count($array)) {
+                       $tRows = array();
                        $fields = array_keys(current($array));
-                                       $tCell[]='
+                       $tCell[] = '
                                                        <td>IDX</td>';
-                               foreach($fields as $fieldName)  {
-                                       $tCell[]='
-                                                       <td>'.htmlspecialchars($fieldName).'</td>';
-                               }
-                               $tRows[]='<tr>'.implode('',$tCell).'</tr>';
+                       foreach ($fields as $fieldName) {
+                               $tCell[] = '
+                                                       <td>' . htmlspecialchars($fieldName) . '</td>';
+                       }
+                       $tRows[] = '<tr>' . implode('', $tCell) . '</tr>';
 
 
-                       foreach($array as $index => $rec)       {
+                       foreach ($array as $index => $rec) {
 
-                               $tCell=array();
-                               $tCell[]='
-                                               <td>'.htmlspecialchars($index).'</td>';
-                               foreach($fields as $fieldName)  {
-                                       $tCell[]='
-                                                       <td>'.htmlspecialchars($rec[$fieldName]).'</td>';
+                               $tCell = array();
+                               $tCell[] = '
+                                               <td>' . htmlspecialchars($index) . '</td>';
+                               foreach ($fields as $fieldName) {
+                                       $tCell[] = '
+                                                       <td>' . htmlspecialchars($rec[$fieldName]) . '</td>';
                                }
-                               $tRows[]='<tr>'.implode('',$tCell).'</tr>';
+                               $tRows[] = '<tr>' . implode('', $tCell) . '</tr>';
                        }
 
-                       return '<table border="1">'.implode('',$tRows).'</table>';
-               } else 'Empty resultset';
+                       return '<table border="1">' . implode('', $tRows) . '</table>';
+               } else {
+                       'Empty resultset';
+               }
        }
 }
 
@@ -853,7 +830,7 @@ class t3lib_sqlengine_resultobj {
         *
         * @return      integer
         */
-       function sql_num_rows() {
+       function sql_num_rows() {
                return count($this->result);
        }
 
@@ -862,7 +839,7 @@ class t3lib_sqlengine_resultobj {
         *
         * @return      array           Associative array
         */
-       function sql_fetch_assoc()      {
+       function sql_fetch_assoc() {
                $row = current($this->result);
                next($this->result);
                return $row;
@@ -873,13 +850,13 @@ class t3lib_sqlengine_resultobj {
         *
         * @return      array           Numerical array
         */
-       function sql_fetch_row()        {
+       function sql_fetch_row() {
                $resultRow = $this->sql_fetch_assoc();
 
-               if (is_array($resultRow))       {
+               if (is_array($resultRow)) {
                        $numArray = array();
-                       foreach($resultRow as $value)   {
-                               $numArray[]=$value;
+                       foreach ($resultRow as $value) {
+                               $numArray[] = $value;
                        }
                        return $numArray;
                }
@@ -891,9 +868,9 @@ class t3lib_sqlengine_resultobj {
         * @param       integer         Position pointer.
         * @return      boolean         Returns true on success
         */
-       function sql_data_seek($pointer)        {
+       function sql_data_seek($pointer) {
                reset($this->result);
-               for ($a=0;$a<$pointer;$a++)     {
+               for ($a = 0; $a < $pointer; $a++) {
                        next($this->result);
                }
                return TRUE;
@@ -904,14 +881,13 @@ class t3lib_sqlengine_resultobj {
         *
         * @return      string          Blank string, not supported (it seems)
         */
-       function sql_field_type()       {
+       function sql_field_type() {
                return '';
        }
 }
 
 
-
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php'])        {
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php']);
 }