Merged branch t3lib_sqlengine 25874:25875 into trunk
authorXavier Perseguers <typo3@perseguers.ch>
Mon, 26 Oct 2009 22:01:19 +0000 (22:01 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Mon, 26 Oct 2009 22:01:19 +0000 (22:01 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@25876 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.sqlengine.php [new file with mode: 0644]
typo3/sysext/dbal/class.ux_t3lib_db.php
typo3/sysext/dbal/class.ux_t3lib_sqlengine.php [deleted file]
typo3/sysext/dbal/class.ux_t3lib_sqlparser.php
typo3/sysext/dbal/ext_autoload.php [new file with mode: 0644]
typo3/sysext/dbal/ext_localconf.php

index 21b8f03..8522959 100644 (file)
@@ -1,3 +1,7 @@
+2009-10-26  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * RFC #12354: Included t3lib_sqlengine locally
+
 2009-10-20  Oliver Hader  <oliver@typo3.org>
 
        * Set version to 0.9.23
diff --git a/typo3/sysext/dbal/class.sqlengine.php b/typo3/sysext/dbal/class.sqlengine.php
new file mode 100644 (file)
index 0000000..3a48d99
--- /dev/null
@@ -0,0 +1,908 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Xavier Perseguers <typo3@perseguers.ch>
+*  (c) 2004-2009 Kasper Skaarhoj <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
+ *
+ * $Id$
+ *
+ * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author Xavier Perseguers <typo3@perseguers.ch>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *  104: class tx_dbal_sqlengine extends ux_t3lib_sqlparser
+ *  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 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: 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)
+ *
+ *
+ *  829: class tx_dbal_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()
+ *
+ * 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.
+ * EXPERIMENTAL!
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class tx_dbal_sqlengine extends ux_t3lib_sqlparser {
+
+               // array with data records: [table name][num.index] = records
+       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.
+
+
+
+
+
+       /**
+        * Dummy function for initializing SQL handler. Create you own in derived classes.
+        *
+        * @param       array           Configuration array from handler
+        * @param       object          Parent object
+        * @return      void
+        */
+       public function init($config, $pObj) {
+       }
+
+       /**
+        * Reset SQL engine status variables (insert id, affected rows, error status)
+        *
+        * @return      void
+        */
+       public function resetStatusVars() {
+               $this->errorStatus = '';
+               $this->lastInsertedId = 0;
+               $this->lastAffectedRows = 0;
+       }
+
+       /**
+        * Processing of update/insert values based on field type.
+        *
+        * The input value is typecast and trimmed/shortened according to the field
+        * type and the configuration options from the $fInfo parameter.
+        *
+        * @param       mixed           $value The input value to process
+        * @param       array           $fInfo Field configuration data
+        * @return      mixed           The processed input value
+        */
+       private function processAccordingToConfig(&$value, $fInfo) {
+               $options = $this->parseFieldDef($fInfo['Type']);
+
+               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);
+                               }
+                       break;
+                       case 'double':
+                               $value = (double)$value;
+                       break;
+                       case 'varchar':
+                       case 'char':
+                               $value = substr($value,0,trim($options['value']));
+                       break;
+                       case 'text':
+                       case 'blob':
+                               $value = substr($value,0,65536);
+                       break;
+                       case 'tinytext':
+                       case 'tinyblob':
+                               $value = substr($value,0,256);
+                       break;
+                       case 'mediumtext':
+                       case 'mediumblob':
+                               // ??
+                       break;
+               }
+       }
+
+
+
+
+
+
+
+       /********************************
+        *
+        * SQL queries
+        * This is the SQL access functions used when this class is instantiated as a SQL handler with DBAL. Override these in derived classes.
+        *
+        ********************************/
+
+       /**
+        * Execute an INSERT query
+        *
+        * @param       string          Table name
+        * @param       array           Field values as key=>value pairs.
+        * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
+        */
+       public function exec_INSERTquery($table, $fields_values) {
+
+                       // Initialize
+               $this->resetStatusVars();
+
+                       // Reading Data Source if not done already.
+               $this->readDataSource($table);
+
+                       // If data source is set:
+               if (is_array($this->data[$table]))      {
+
+                       $fieldInformation = $this->admin_get_fields($table);            // Should cache this...!
+
+                               // Looking for unique keys:
+                       $saveArray = array();
+                       foreach($fieldInformation as $fInfo)    {
+
+                                       // Field name:
+                               $fN = $fInfo['Field'];
+
+                                       // Set value:
+// 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')        {
+
+                                               // Get all UIDs:
+                                       $uidArray = array();
+                                       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;
+                                       }
+
+                                               // Update "last inserted id":
+                                       $this->lastInsertedId = $saveArray[$fN];
+                               }
+                       }
+
+                               // Insert row in table:
+                       $this->data[$table][] = $saveArray;
+
+                               // Save data source
+                       $this->saveDataSource($table);
+
+                       return TRUE;
+               } else $this->errorStatus = 'No data loaded.';
+
+               return FALSE;
+       }
+
+       /**
+        * Execute UPDATE query on table
+        *
+        * @param       string          Table name
+        * @param       string          WHERE clause
+        * @param       array           Field values as key=>value pairs.
+        * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
+        */
+       public function exec_UPDATEquery($table, $where, $fields_values) {
+
+                       // Initialize:
+               $this->resetStatusVars();
+
+                       // Reading Data Source if not done already.
+               $this->readDataSource($table);
+
+                       // If anything is there:
+               if (is_array($this->data[$table]))      {
+
+                               // Parse WHERE clause:
+                       $where = $this->parseWhereClause($where);
+
+                       if (is_array($where))   {
+
+                                       // Field information
+                               $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]);
+                               }
+
+                                       // Do query, returns array with keys to the data array of the result:
+                               $itemKeys = $this->selectFromData($table,$where);
+
+                                       // Set "last affected rows":
+                               $this->lastAffectedRows = count($itemKeys);
+
+                                       // Update rows:
+                               if ($this->lastAffectedRows)    {
+                                               // Traverse result set here:
+                                       foreach($itemKeys as $dataArrayKey)     {
+
+                                                       // Traverse fields to update:
+                                               foreach($fields_values as $fName => $fValue)    {
+                                                       $this->data[$table][$dataArrayKey][$fName] = $fValue;
+                                               }
+                                       }
+
+                                       // Save data source
+                                       $this->saveDataSource($table);
+                               }
+
+                               return TRUE;
+                       } else $this->errorStatus = 'WHERE clause contained errors: '.$where;
+               } else $this->errorStatus = 'No data loaded.';
+
+               return FALSE;
+       }
+
+       /**
+        * Execute DELETE query
+        *
+        * @param       string          Table to delete from
+        * @param       string          WHERE clause
+        * @return      boolean         TRUE on success and FALSE on failure (error is set internally)
+        */
+       public function exec_DELETEquery($table, $where) {
+
+                       // Initialize:
+               $this->resetStatusVars();
+
+                       // Reading Data Source if not done already.
+               $this->readDataSource($table);
+
+                       // If anything is there:
+               if (is_array($this->data[$table]))      {
+
+                               // Parse WHERE clause:
+                       $where = $this->parseWhereClause($where);
+
+                       if (is_array($where))   {
+
+                                       // Do query, returns array with keys to the data array of the result:
+                               $itemKeys = $this->selectFromData($table,$where);
+
+                                       // Set "last affected rows":
+                               $this->lastAffectedRows = count($itemKeys);
+
+                                       // Remove rows:
+                               if ($this->lastAffectedRows)    {
+                                               // Traverse result set:
+                                       foreach($itemKeys as $dataArrayKey)     {
+                                               unset($this->data[$table][$dataArrayKey]);
+                                       }
+
+                                               // Saving data source
+                                       $this->saveDataSource($table);
+                               }
+
+                               return TRUE;
+                       } else $this->errorStatus = 'WHERE clause contained errors: '.$where;
+               } else $this->errorStatus = 'No data loaded.';
+
+               return FALSE;
+       }
+
+       /**
+        * Execute SELECT query
+        *
+        * @param       string          List of fields to select from the table. This is what comes right after "SELECT ...". Required value.
+        * @param       string          Table(s) from which to select. This is what comes right after "FROM ...". Required value.
+        * @param       string          Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
+        * @param       string          Optional GROUP BY field(s), if none, supply blank string.
+        * @param       string          Optional ORDER BY field(s), if none, supply blank string.
+        * @param       string          Optional LIMIT value ([begin,]max), if none, supply blank string.
+        * @return      object          Returns result object, but if errors, returns false
+        */
+       public function exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit) {
+
+                       // Initialize:
+               $this->resetStatusVars();
+
+                       // Create result object
+               $sqlObj = t3lib_div::makeInstance('tx_dbal_sqlengine_resultobj');
+               $sqlObj->result = array();      // Empty result as a beginning
+
+                       // Get table list:
+               $tableArray = $this->parseFromTables($from_table);
+               $table = $tableArray[0]['table'];
+
+                       // Reading Data Source if not done already.
+               $this->readDataSource($table);
+
+                       // If anything is there:
+               if (is_array($this->data[$table]))      {
+
+                               // Parse WHERE clause:
+                       $where = $this->parseWhereClause($where_clause);
+                       if (is_array($where))   {
+
+                                       // Do query, returns array with keys to the data array of the result:
+                               $itemKeys = $this->selectFromData($table,$where);
+
+                                       // Finally, read the result rows into this variable:
+                               $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;
+
+               return FALSE;
+       }
+
+       /**
+        * Performs an SQL query on the "database"
+        *
+        * @param       string          Query to execute
+        * @return      object          Result object or false if error
+        */
+       public function sql_query($query) {
+               $res = t3lib_div::makeInstance('tx_dbal_sqlengine_resultobj');
+               $res->result = array();
+               return $res;
+       }
+
+       /**
+        * Returns most recent error
+        *
+        * @return      string          Error message, if any
+        */
+       public function sql_error() {
+               return $this->errorStatus;
+       }
+
+       /**
+        * Returns most recently create unique ID (of INSERT queries)
+        *
+        * @return      integer         Last unique id created.
+        */
+       public function sql_insert_id() {
+               return $this->lastInsertedId;
+       }
+
+       /**
+        * Returns affected rows (of UPDATE and DELETE queries)
+        *
+        * @return      integer         Last amount of affected rows.
+        */
+       public function sql_affected_rows() {
+               return $this->lastAffectedRows;
+       }
+
+       /**
+        * Quoting strings for insertion in SQL queries
+        *
+        * @param       string          Input String
+        * @return      string          String, with quotes escaped
+        */
+       public function quoteStr($str) {
+               return addslashes($str);
+       }
+
+
+
+
+
+
+
+
+
+
+       /**************************************
+        *
+        * SQL admin functions
+        * (For use in the Install Tool and Extension Manager)
+        *
+        **************************************/
+
+       /**
+        * (DUMMY) Returns the list of tables from the database
+        *
+        * @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()
+        */
+       public function admin_get_tables() {
+               $whichTables = array();
+               return $whichTables;
+       }
+
+       /**
+        * (DUMMY) Returns information about each field in the $table
+        *
+        * @param       string          Table name
+        * @return      array           Field information in an associative array with fieldname => field row
+        */
+       public function admin_get_fields($tableName) {
+               $output = array();
+               return $output;
+       }
+
+       /**
+        * (DUMMY) Returns information about each index key in the $table
+        *
+        * @param       string          Table name
+        * @return      array           Key information in a numeric array
+        */
+       public function admin_get_keys($tableName) {
+               $output = array();
+               return $output;
+       }
+
+       /**
+        * (DUMMY) mysql() wrapper function, used by the Install Tool and EM for all queries regarding management of the database!
+        *
+        * @param       string          Query to execute
+        * @return      pointer         Result pointer
+        */
+       public function admin_query($query) {
+               return $this->sql_query($query);
+       }
+
+
+
+
+
+
+
+
+       /********************************
+        *
+        * Data Source I/O
+        *
+        ********************************/
+
+       /**
+        * Dummy function for setting table data. Create your own.
+        * NOTICE: Handler to "table-locking" needs to be made probably!
+        *
+        * @param       string          Table name
+        * @return      void
+        * @todo        Table locking tools?
+        */
+       public function readDataSource($table) {
+               $this->data[$table] = array();
+       }
+
+       /**
+        * Dummy function for setting table data. Create your own.
+        * NOTICE: Handler to "table-locking" needs to be made probably!
+        *
+        * @param       string          Table name
+        * @return      void
+        * @todo        Table locking tools?
+        */
+       public function saveDataSource($table) {
+               debug($this->data[$table]);
+       }
+
+
+
+
+
+
+
+
+
+
+
+
+
+       /********************************
+        *
+        * SQL engine functions (PHP simulation of SQL) - still experimental
+        *
+        ********************************/
+
+       /**
+        * PHP simulation of SQL "SELECT"
+        * Yet EXPERIMENTAL!
+        *
+        * @param       string          Table name
+        * @param       array           Where clause parsed into array
+        * @return      array           Array of keys pointing to result rows in $this->data[$table]
+        */
+       public function selectFromData($table, $where) {
+
+               $output = array();
+               if (is_array($this->data[$table]))      {
+
+                               // All keys:
+                       $OR_index = 0;
+
+                       foreach($where as $config)      {
+
+                               if (strtoupper($config['operator'])=='OR')      {
+                                       $OR_index++;
+                               }
+
+                               if (!isset($itemKeys[$OR_index]))       $itemKeys[$OR_index] = array_keys($this->data[$table]);
+
+                               $this->select_evalSingle($table,$config,$itemKeys[$OR_index]);
+                       }
+
+                       foreach($itemKeys as $uidKeys)  {
+                               $output = array_merge($output, $uidKeys);
+                       }
+                       $output = array_unique($output);
+               }
+
+               return $output;
+       }
+
+       /**
+        * Evalutaion of a WHERE-clause-array.
+        * Yet EXPERIMENTAL
+        *
+        * @param       string          Tablename
+        * @param       array           WHERE-configuration array
+        * @param       array           Data array to work on.
+        * @return      void            Data array passed by reference
+        * @see selectFromData()
+        */
+       public 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]);
+                                       }
+                               }
+                       } else {
+                               $itemKeys = array_intersect($itemKeys, $subSelKeys);
+                       }
+               } else {
+                       $comp = strtoupper(str_replace(array(' ',"\t","\r","\n"),'',$config['comparator']));
+                       $mod = strtoupper($config['modifier']);
+                       switch($comp)   {
+                               case 'NOTLIKE':
+                               case 'LIKE':
+                                       $like_value = strtolower($config['value'][0]);
+                                       if (substr($like_value,0,1)=='%')       {
+                                               $wildCard_begin = TRUE;
+                                               $like_value = substr($like_value,1);
+                                       }
+                                       if (substr($like_value,-1)=='%')        {
+                                               $wildCard_end = TRUE;
+                                               $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];
+                                       }
+                               break;
+                       }
+
+                       foreach($itemKeys as $kk => $v) {
+                               $field_value = $this->data[$table][$v][$config['field']];
+
+                                       // Calculate it:
+                               if ($config['calc']=='&')       {
+                                       $field_value&=intval($config['calc_value']);
+                               }
+
+                                       // Compare it:
+                               switch($comp)   {
+                                       case '<=':
+                                               $bool = $field_value <= $config['value'][0];
+                                       break;
+                                       case '>=':
+                                               $bool = $field_value >= $config['value'][0];
+                                       break;
+                                       case '<':
+                                               $bool = $field_value < $config['value'][0];
+                                       break;
+                                       case '>':
+                                               $bool = $field_value > $config['value'][0];
+                                       break;
+                                       case '=':
+                                               $bool = !strcmp($field_value,$config['value'][0]);
+                                       break;
+                                       case '!=':
+                                               $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;
+                                       break;
+                                       case 'NOTLIKE':
+                                       case 'LIKE':
+                                               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);
+                                               } else {
+                                                       $bool = !strcmp(strtolower($field_value),$like_value);
+                                               }
+                                               if ($comp=='NOTLIKE')   $bool = !$bool;
+                                       break;
+                                       default:
+                                               $bool = $field_value ? TRUE : FALSE;
+                                       break;
+                               }
+
+                                       // General negation:
+                               if ($neg)       $bool = !$bool;
+
+                                       // Modify?
+                               switch($mod)    {
+                                       case 'NOT':
+                                       case '!':
+                                               $bool = !$bool;
+                                       break;
+                               }
+
+                                       // Action:
+                               if (!$bool)     {
+                                       unset($itemKeys[$kk]);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Returning result set based on result keys, table and field list
+        *
+        * @param       array           Result keys
+        * @param       string          Tablename
+        * @param       string          Fieldlist (commaseparated)
+        * @return      array           Result array with "rows"
+        */
+       public function getResultSet($keys, $table, $fieldList) {
+               $fields = t3lib_div::trimExplode(',',$fieldList);
+
+               $output = array();
+               foreach($keys as $kValue)       {
+                       if ($fieldList=='*')    {
+                               $output[$kValue] = $this->data[$table][$kValue];
+                       } else {
+                               foreach($fields as $fieldName)  {
+                                       $output[$kValue][$fieldName] = $this->data[$table][$kValue][$fieldName];
+                               }
+                       }
+               }
+
+               return $output;
+       }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+       /*************************
+        *
+        * Debugging
+        *
+        *************************/
+
+       /**
+        * Returns the result set (in array) as HTML table. For debugging.
+        *
+        * @param       array           Result set array (array of rows)
+        * @return      string          HTML table
+        */
+       public function debug_printResultSet($array) {
+
+               if (count($array))      {
+                       $tRows=array();
+                       $fields = array_keys(current($array));
+                                       $tCell[]='
+                                                       <td>IDX</td>';
+                               foreach($fields as $fieldName)  {
+                                       $tCell[]='
+                                                       <td>'.htmlspecialchars($fieldName).'</td>';
+                               }
+                               $tRows[]='<tr>'.implode('',$tCell).'</tr>';
+
+
+                       foreach($array as $index => $rec)       {
+
+                               $tCell=array();
+                               $tCell[]='
+                                               <td>'.htmlspecialchars($index).'</td>';
+                               foreach($fields as $fieldName)  {
+                                       $tCell[]='
+                                                       <td>'.htmlspecialchars($rec[$fieldName]).'</td>';
+                               }
+                               $tRows[]='<tr>'.implode('',$tCell).'</tr>';
+                       }
+
+                       return '<table border="1">'.implode('',$tRows).'</table>';
+               } else 'Empty resultset';
+       }
+}
+
+
+/**
+ * PHP SQL engine, result object
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage dbal
+ */
+class tx_dbal_sqlengine_resultobj {
+
+               // Result array, must contain the fields in the order they were selected in the SQL statement (for sql_fetch_row())
+       var $result = array();
+
+       var $TYPO3_DBAL_handlerType = '';
+       var $TYPO3_DBAL_tableList = '';
+
+
+       /**
+        * Counting number of rows
+        *
+        * @return      integer
+        */
+       public function sql_num_rows() {
+               return count($this->result);
+       }
+
+       /**
+        * Fetching next row in result array
+        *
+        * @return      array           Associative array
+        */
+       public function sql_fetch_assoc() {
+               $row = current($this->result);
+               next($this->result);
+               return $row;
+       }
+
+       /**
+        * Fetching next row, numerical indices
+        *
+        * @return      array           Numerical array
+        */
+       public function sql_fetch_row() {
+               $resultRow = $this->sql_fetch_assoc();
+
+               if (is_array($resultRow))       {
+                       $numArray = array();
+                       foreach($resultRow as $value)   {
+                               $numArray[]=$value;
+                       }
+                       return $numArray;
+               }
+       }
+
+       /**
+        * Seeking position in result
+        *
+        * @param       integer         Position pointer.
+        * @return      boolean         Returns true on success
+        */
+       public function sql_data_seek($pointer) {
+               reset($this->result);
+               for ($a=0;$a<$pointer;$a++)     {
+                       next($this->result);
+               }
+               return TRUE;
+       }
+
+       /**
+        * Returning SQL field type
+        *
+        * @return      string          Blank string, not supported (it seems)
+        */
+       public function sql_field_type() {
+               return '';
+       }
+}
+
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.sqlengine.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.sqlengine.php']);
+}
+
+?>
index 9cb1835..4a4fb71 100644 (file)
@@ -155,7 +155,7 @@ class ux_t3lib_DB extends t3lib_DB {
        /**
         * SQL parser
         *
-        * @var t3lib_sqlengine
+        * @var tx_dbal_sqlengine
         */
        var $SQLparser;
 
@@ -176,7 +176,7 @@ class ux_t3lib_DB extends t3lib_DB {
        function ux_t3lib_DB()  {
 
                // Set SQL parser object for internal use:
-               $this->SQLparser = t3lib_div::makeInstance('t3lib_sqlengine');
+               $this->SQLparser = t3lib_div::makeInstance('tx_dbal_sqlengine');
                $this->Installer = t3lib_div::makeInstance('t3lib_install');
 
                // Set internal variables with configuration:
@@ -2389,7 +2389,7 @@ class ux_t3lib_DB extends t3lib_DB {
        }
 
        /**
-        * Generic mapping of table/field names arrays (as parsed by t3lib_sqlengine)
+        * Generic mapping of table/field names arrays (as parsed by tx_dbal_sqlengine)
         *
         * @param       array           Array with parsed SQL parts; Takes both fields, tables, where-parts, group and order-by. Passed by reference.
         * @param       string          Default table name to assume if no table is found in $sqlPartArray
@@ -2469,12 +2469,12 @@ class ux_t3lib_DB extends t3lib_DB {
        }
 
        /**
-        * Will do table/field mapping on a general t3lib_sqlengine-compliant SQL query
+        * Will do table/field mapping on a general tx_dbal_sqlengine-compliant SQL query
         * (May still not support all query types...)
         *
-        * @param       array           Parsed QUERY as from t3lib_sqlengine::parseSQL(). NOTICE: Passed by reference!
+        * @param       array           Parsed QUERY as from tx_dbal_sqlengine::parseSQL(). NOTICE: Passed by reference!
         * @return      void
-        * @see t3lib_sqlengine::parseSQL()
+        * @see tx_dbal_sqlengine::parseSQL()
         */
        function map_genericQueryParsed(&$parsedQuery)  {
 
diff --git a/typo3/sysext/dbal/class.ux_t3lib_sqlengine.php b/typo3/sysext/dbal/class.ux_t3lib_sqlengine.php
deleted file mode 100644 (file)
index 5cded2e..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2004-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  (c) 2004-2009 Karsten Dambekalns <karsten@typo3.org>
-*  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
- *
- * $Id$
- *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @author     Karsten Dambekalns <k.dambekalns@fishfarm.de>
- */
-
-
-/**
- * PHP SQL engine / server
- * Some parts are experimental for now.
- *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
- * @package TYPO3
- * @subpackage t3lib
- */
-class ux_t3lib_sqlengine extends t3lib_sqlengine {
-
-       /*************************
-        *
-        * Compiling queries
-        *
-        *************************/
-
-       /**
-        * Compiles an SQL query from components
-        *
-        * @param       array           Array of SQL query components
-        * @return      string          SQL query
-        * @see parseSQL()
-        */
-       function compileSQL($components)        {
-
-               switch($components['type'])     {
-                       case 'SELECT':
-                               $query = $this->compileSELECT($components);
-                               break;
-                       case 'UPDATE':
-                               $query = $this->compileUPDATE($components);
-                               break;
-                       case 'INSERT':
-                               $query = $this->compileINSERT($components);
-                               break;
-                       case 'DELETE':
-                               $query = $this->compileDELETE($components);
-                               break;
-                       case 'EXPLAIN':
-                               $query = 'EXPLAIN '.$this->compileSELECT($components);
-                               break;
-                       case 'DROPTABLE':
-                               $query = $this->compileDROPTABLE($components);
-                               break;
-                       case 'CREATETABLE':
-                               $query = $this->compileCREATETABLE($components);
-                               break;
-                       case 'ALTERTABLE':
-                               $query = $this->compileALTERTABLE($components);
-                               break;
-               }
-
-               return $query;
-       }
-
-
-       function compileINSERT($components)     {
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
-                       case 'native':
-                               $query = parent::compileINSERT($components);
-                               break;
-                       case 'adodb':
-                               if(isset($components['VALUES_ONLY']) && is_array($components['VALUES_ONLY'])) {
-                                       $fields = $GLOBALS['TYPO3_DB']->cache_fieldType[$components['TABLE']];
-                                       $fc = 0;
-                                       foreach($fields as $fn => $fd) {
-                                               $query[$fn] = $components['VALUES_ONLY'][$fc++][0];
-                                       }
-                               } else {
-                                               // Initialize:
-                                       foreach($components['FIELDS'] as $fN => $fV)    {
-                                               $query[$fN]=$fV[0];
-                                       }
-                               }
-                               break;
-               }
-
-               return $query;
-       }
-
-       function compileDROPTABLE($components)  {
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
-                       case 'native':
-                               $query = 'DROP TABLE'.($components['ifExists']?' IF EXISTS':'').' '.$components['TABLE'];
-                               break;
-                       case 'adodb':
-                               $handlerKey = $GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE']);
-                               $tableName = $GLOBALS['TYPO3_DB']->quoteName($components['TABLE'], $handlerKey, TRUE);
-                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$handlerKey]->DataDictionary->DropTableSQL($tableName);
-                               break;
-               }
-
-               return $query;
-       }
-
-       /**
-        * Compiles a CREATE TABLE statement from components array
-        *
-        * @param       array           Array of SQL query components
-        * @return      array           array with SQL CREATE TABLE/INDEX command(s)
-        * @see parseCREATETABLE()
-        */
-       function compileCREATETABLE($components)        {
-                       // Execute query (based on handler derived from the TABLE name which we actually know for once!)
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]['type'])  {
-                       case 'native':
-                               $query[] = parent::compileCREATETABLE($components);
-                               break;
-                       case 'adodb':
-                                       // Create fields and keys:
-                               $fieldsKeys = array();
-                               $indexKeys = array();
-
-                               foreach($components['FIELDS'] as $fN => $fCfg)  {
-                                       $handlerKey = $GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE']);
-                                       $fieldsKeys[$fN] = $GLOBALS['TYPO3_DB']->quoteName($fN, $handlerKey, TRUE) . ' ' . $this->compileFieldCfg($fCfg['definition']);
-                               }
-
-                               if(isset($components['KEYS']) && is_array($components['KEYS'])) {
-                                       foreach($components['KEYS'] as $kN => $kCfg)    {
-                                               if ($kN == 'PRIMARYKEY')        {
-                                                       foreach($kCfg as $n => $field)  {
-                                                               $fieldsKeys[$field] .= ' PRIMARY';
-                                                       }
-                                               } elseif ($kN == 'UNIQUE')      {
-                                                       foreach($kCfg as $n => $field)  {
-                                                               $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($n, $components['TABLE'], $field, array('UNIQUE')));
-                                                       }
-                                               } else {
-                                                       $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($components['TABLE'].'_'.$kN, $components['TABLE'], $kCfg));
-                                               }
-                                       }
-                               }
-
-                                       // generally create without OID on PostgreSQL
-                               $tableOptions = array('postgres' => 'WITHOUT OIDS');
-
-                                       // Fetch table/index generation query:
-                               $tableName = $GLOBALS['TYPO3_DB']->quoteName($components['TABLE'], NULL, TRUE);
-                               $query = array_merge($GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->CreateTableSQL($tableName, implode(',' . chr(10), $fieldsKeys), $tableOptions), $indexKeys);
-                               break;
-               }
-
-               return $query;
-       }
-
-       function compileALTERTABLE($components) {
-                       // Execute query (based on handler derived from the TABLE name which we actually know for once!)
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
-                       case 'native':
-                               $query[] = parent::compileALTERTABLE($components);
-                               break;
-                       case 'adodb':
-                               $tableName = $GLOBALS['TYPO3_DB']->quoteName($components['TABLE'], NULL, TRUE);
-                               $fieldName = $GLOBALS['TYPO3_DB']->quoteName($components['FIELD'], NULL, TRUE);
-                               switch(strtoupper(str_replace(array(" ","\n","\r","\t"),'',$components['action'])))     {
-                                       case 'ADD':
-                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AddColumnSQL($tableName, $fieldName . ' ' . $this->compileFieldCfg($components['definition']));
-                                               break;
-                                       case 'CHANGE':
-                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AlterColumnSQL($tableName, $fieldName . ' ' . $this->compileFieldCfg($components['definition']));
-                                               break;
-                                       case 'DROP':
-                                       case 'DROPKEY':
-                                               break;
-                                       case 'ADDKEY':
-                                       case 'ADDPRIMARYKEY':
-                                               $query.=' ('.implode(',',$components['fields']).')';
-                                               break;
-                               }
-                               break;
-               }
-
-               return $query;
-       }
-
-       /**
-        * Compile field definition
-        *
-        * @param       array           Field definition parts
-        * @return      string          Field definition string
-        */
-       function compileFieldCfg($fieldCfg)     {
-
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
-                       case 'native':
-                               $cfg = parent::compileFieldCfg($fieldCfg);
-                               break;
-                       case 'adodb':
-                                       // Set type:
-                               $type = $GLOBALS['TYPO3_DB']->MySQLMetaType($fieldCfg['fieldType']);
-                               $cfg = $type;
-
-                                       // Add value, if any:
-                               if (strlen($fieldCfg['value']) && (in_array($type, array('C','C2'))))   {
-                                       $cfg .= ' '.$fieldCfg['value'];
-                               } elseif (!isset($fieldCfg['value']) && (in_array($type, array('C','C2')))) {
-                                       $cfg .= ' 255'; // add 255 as length for varchar without specified length (e.g. coming from tinytext, tinyblob)
-                               }
-
-                                       // Add additional features:
-                               if (is_array($fieldCfg['featureIndex']))        {
-
-                                               // MySQL assigns DEFAULT value automatically if NOT NULL, fake this here
-                                               // numeric fields get 0 as default, other fields an empty string
-                                       if(isset($fieldCfg['featureIndex']['NOTNULL']) && !isset($fieldCfg['featureIndex']['DEFAULT']) && !isset($fieldCfg['featureIndex']['AUTO_INCREMENT'])) {
-                                               switch($type) {
-                                                       case 'I8':
-                                                       case 'F':
-                                                       case 'N':
-                                                               $fieldCfg['featureIndex']['DEFAULT'] = array('keyword' => 'DEFAULT', 'value' => array('0',''));
-                                                               break;
-                                                       default:
-                                                               $fieldCfg['featureIndex']['DEFAULT'] = array('keyword' => 'DEFAULT', 'value' => array('','\''));
-                                               }
-                                       }
-
-                                       foreach($fieldCfg['featureIndex'] as $feature => $featureDef)   {
-                                               switch(true) {
-                                                               // unsigned only for mysql, as it is mysql specific
-                                                       case ($feature == 'UNSIGNED' && !$GLOBALS['TYPO3_DB']->runningADOdbDriver('mysql')) :
-                                                               // auto_increment is removed, it is handled by (emulated) sequences
-                                                       case ($feature == 'AUTO_INCREMENT') :
-                                                               // never add NOT NULL if running on Oracle and we have an empty string as default
-                                                       case ($feature == 'NOTNULL' && $GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8')) :
-                                                               continue;
-                                                       case ($feature == 'NOTNULL') :
-                                                       $cfg.=' NOTNULL';
-                                                               break;
-                                                       default :
-                                                       $cfg.=' '.$featureDef['keyword'];
-                                               }
-
-                                                       // Add value if found:
-                                               if (is_array($featureDef['value']))     {
-                                                       if($featureDef['value'][0]==='') {
-                                                               $cfg .= ' "\'\'"';
-                                                       } else {
-                                                               $cfg.=' '.$featureDef['value'][1].$this->compileAddslashes($featureDef['value'][0]).$featureDef['value'][1];
-                                                       }
-                                               }
-                                       }
-                               }
-                               $cfg .= ' NOQUOTE';
-                               break;
-               }
-
-                       // Return field definition string:
-               return $cfg;
-       }
-
-       function checkEmptyDefaultValue($featureIndex) {
-               if (is_array($featureIndex['DEFAULT']['value']))        {
-                       if(!is_numeric($featureIndex['DEFAULT']['value'][0]) && empty($featureIndex['DEFAULT']['value'][0])) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-               return true;
-       }
-
-       /**
-        * Implodes an array of WHERE clause configuration into a WHERE clause.
-        *
-        * DBAL-specific: The only(!) handled "calc" operator supported by parseWhereClause() is the bitwise
-        * logical and (&), and only this one is supported here!
-        *
-        * @param       array           WHERE clause configuration
-        * @return      string          WHERE clause as string.
-        * @see t3lib_sqlparser::parseWhereClause()
-        */
-       function compileWhereClause($clauseArray, $functionMapping = true)       {
-               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
-                       case 'native':
-                               $output = parent::compileWhereClause($clauseArray);
-                               break;
-                       case 'adodb':
-                               // Prepare buffer variable:
-                               $output='';
-
-                               // Traverse clause array:
-                               if (is_array($clauseArray))     {
-                                       foreach($clauseArray as $k => $v)       {
-
-                                               // Set operator:
-                                               $output.=$v['operator'] ? ' '.$v['operator'] : '';
-
-                                               // Look for sublevel:
-                                               if (is_array($v['sub']))        {
-                                                       $output.=' ('.trim($this->compileWhereClause($v['sub'], $functionMapping)).')';
-                                               } else {
-
-                                                       // Set field/table with modifying prefix if any:
-                                                       $output.=' '.trim($v['modifier']).' ';
-
-                                                       // DBAL-specific: Set calculation, if any:
-                                                       if ($v['calc'] && $functionMapping)     {
-                                                               switch(true) {
-                                                                       case $GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8'):
-                                                                                       // Oracle only knows BITAND(x,y) - sigh
-                                                                               $output.='BITAND('.trim(($v['table']?$v['table'].'.':'').$v['field']).','.$v['calc_value'][1].$this->compileAddslashes($v['calc_value'][0]).$v['calc_value'][1].')';
-                                                                               break;
-                                                                       default:
-                                                                                       // MySQL, MS SQL Server, PostgreSQL support the &-syntax
-                                                                               $output.=trim(($v['table']?$v['table'].'.':'').$v['field']).$v['calc'].$v['calc_value'][1].$this->compileAddslashes($v['calc_value'][0]).$v['calc_value'][1];
-                                                                               break;
-                                                               }
-                                                       } elseif ($v['calc'])   {
-                                                               $output.=trim(($v['table']?$v['table'].'.':'').$v['field']).$v['calc'].$v['calc_value'][1].$this->compileAddslashes($v['calc_value'][0]).$v['calc_value'][1];
-                                                       } elseif(!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator']==='LIKE' && $functionMapping)) {
-                                                               $output.=trim(($v['table']?$v['table'].'.':'').$v['field']);
-                                                       }
-
-                                                       // Set comparator:
-                                                       if ($v['comparator'])   {
-                                                               switch(true) {
-                                                                       case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator']==='LIKE' && $functionMapping):
-                                                                                       // Oracle cannot handle LIKE on CLOB fields - sigh
-                                                                                       $output .= '(dbms_lob.instr('.trim(($v['table']?$v['table'].'.':'').$v['field']).', '.$v['value'][1].$this->compileAddslashes(trim($v['value'][0], '%')).$v['value'][1].',1,1) > 0)';
-                                                                               break;
-                                                                       default:
-                                                                               $output.=' '.$v['comparator'];
-
-                                                                               // Detecting value type; list or plain:
-                                                                               if (t3lib_div::inList('NOTIN,IN',strtoupper(str_replace(array(' ',"\t","\r","\n"),'',$v['comparator']))))       {
-                                                                                       $valueBuffer = array();
-                                                                                       foreach($v['value'] as $realValue)      {
-                                                                                               $valueBuffer[]=$realValue[1].$this->compileAddslashes($realValue[0]).$realValue[1];
-                                                                                       }
-                                                                                       $output.=' ('.trim(implode(',',$valueBuffer)).')';
-                                                                               } else {
-                                                                                       $output.=' '.$v['value'][1].$this->compileAddslashes($v['value'][0]).$v['value'][1];
-                                                                               }
-                                                                               break;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                               break;
-               }
-
-               return $output;
-       }
-}
-
-
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_sqlengine.php'])  {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_sqlengine.php']);
-}
-
-?>
index 368e6db..8c8754e 100644 (file)
@@ -94,7 +94,7 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
        function compileINSERT($components)     {
                switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
                        case 'native':
-                               parent::compileINSERT($components);
+                               $query = parent::compileINSERT($components);
                                break;
                        case 'adodb':
                                if(isset($components['VALUES_ONLY']) && is_array($components['VALUES_ONLY'])) {
@@ -357,10 +357,11 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
                                                                }
                                                        } elseif ($v['calc'])   {
                                                                $output.=trim(($v['table']?$v['table'].'.':'').$v['field']).$v['calc'].$v['calc_value'][1].$this->compileAddslashes($v['calc_value'][0]).$v['calc_value'][1];
-                                                       } else {
+                                                       } elseif(!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator']==='LIKE' && $functionMapping)) {
                                                                $output.=trim(($v['table']?$v['table'].'.':'').$v['field']);
                                                        }
 
+                                                       // Set comparator:
                                                        if ($v['comparator'])   {
                                                                switch(true) {
                                                                        case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator']==='LIKE' && $functionMapping):
@@ -382,7 +383,8 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
                                                                                }
                                                                                break;
                                                                }
-                                                       }                                               }
+                                                       }
+                                               }
                                        }
                                }
                                break;
diff --git a/typo3/sysext/dbal/ext_autoload.php b/typo3/sysext/dbal/ext_autoload.php
new file mode 100644 (file)
index 0000000..7d69786
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+// DO NOT CHANGE THIS FILE! It is automatically generated by extdeveval::buildAutoloadRegistry.
+// This file was generated on 2009-10-26 22:04
+
+
+$extensionPath = t3lib_extMgm::extPath('dbal');
+return array(
+       'tx_dbal_sqlengine' => $extensionPath . 'class.sqlengine.php',
+       'ux_t3lib_sqlparser' => $extensionPath . 'class.ux_t3lib_sqlparser.php',
+);
+?>
index be6facb..051e1a0 100644 (file)
@@ -2,8 +2,7 @@
 if (!defined ('TYPO3_MODE'))   die ('Access denied.');
 
 $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_db.php'] = t3lib_extMgm::extPath('dbal').'class.ux_t3lib_db.php';
-$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php'] = t3lib_extMgm::extPath('dbal').'class.ux_t3lib_sqlengine.php';
 $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlparser.php'] = t3lib_extMgm::extPath('dbal').'class.ux_t3lib_sqlparser.php';
 $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'] = t3lib_extMgm::extPath('dbal').'class.ux_db_list_extra.php';
 
-?>
\ No newline at end of file
+?>