Committed DBAL extension as a sysext. Older changes can be looked up in the TYPO3xdev...
authorKarsten Dambekalns <karsten.dambekalns@typo3.org>
Tue, 27 Dec 2005 15:00:34 +0000 (15:00 +0000)
committerKarsten Dambekalns <karsten.dambekalns@typo3.org>
Tue, 27 Dec 2005 15:00:34 +0000 (15:00 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@23835 735d13b6-9817-0410-8766-e36946ffe9aa

21 files changed:
typo3/sysext/dbal/ChangeLog [new file with mode: 0644]
typo3/sysext/dbal/class.ux_t3lib_db.php [new file with mode: 0644]
typo3/sysext/dbal/class.ux_t3lib_sqlengine.php [new file with mode: 0644]
typo3/sysext/dbal/class.ux_t3lib_sqlparser.php [new file with mode: 0644]
typo3/sysext/dbal/doc/TODO.txt [new file with mode: 0644]
typo3/sysext/dbal/doc/manual.sxw [new file with mode: 0644]
typo3/sysext/dbal/ext_emconf.php [new file with mode: 0644]
typo3/sysext/dbal/ext_icon.gif [new file with mode: 0644]
typo3/sysext/dbal/ext_localconf.php [new file with mode: 0644]
typo3/sysext/dbal/ext_php_api.dat [new file with mode: 0644]
typo3/sysext/dbal/ext_tables.php [new file with mode: 0644]
typo3/sysext/dbal/ext_tables.sql [new file with mode: 0644]
typo3/sysext/dbal/handlers/class.tx_dbal_handler_openoffice.php [new file with mode: 0644]
typo3/sysext/dbal/handlers/class.tx_dbal_handler_rawmysql.php [new file with mode: 0644]
typo3/sysext/dbal/handlers/class.tx_dbal_handler_xmldb.php [new file with mode: 0644]
typo3/sysext/dbal/mod1/clear.gif [new file with mode: 0644]
typo3/sysext/dbal/mod1/conf.php [new file with mode: 0644]
typo3/sysext/dbal/mod1/index.php [new file with mode: 0644]
typo3/sysext/dbal/mod1/locallang.xml [new file with mode: 0644]
typo3/sysext/dbal/mod1/locallang_mod.xml [new file with mode: 0644]
typo3/sysext/dbal/mod1/moduleicon.gif [new file with mode: 0644]

diff --git a/typo3/sysext/dbal/ChangeLog b/typo3/sysext/dbal/ChangeLog
new file mode 100644 (file)
index 0000000..ac266cf
--- /dev/null
@@ -0,0 +1,72 @@
+2005-12-27  Karsten Dambekalns <karsten@typo3.org>
+
+       * Converted locallang to XML, small adaptions to syext location.
+       * One slight fix to the SQL check in the BE module (wrong output if
+       an error occurred).
+
+2005-12-26  Karsten Dambekalns <karsten@typo3.org>
+
+       * Code cleanup and improvements to the mapping. Merged 3rd
+       party changes done by DIACC GmbH.
+
+2005-12-23  Karsten Dambekalns <karsten@typo3.org>
+
+       * Fixed a few issues that were left undiscovered yet.
+       * Added a new module to test query building and parsing
+       from the DBAL debug module.
+       * Finalized fix for bug #1649.
+
+2005-12-22  Karsten Dambekalns <karsten@typo3.org>
+
+       * Fixed bug #2077 (NOT handling breaking, consequently
+       discarding WHERE clauses).
+
+2005-12-21  Karsten Dambekalns <karsten@typo3.org>
+
+       * Fixed bug #1781 to allow easier install.
+       * Closed bug #1204 as not reproducable. Probably rather a
+       PHP/Apache bug than a DBAL bug.
+       * Closed bug #1317 which has been fixed earlier. It was due
+       to a msissing check for the incoming SQL (string/array) in the
+       native part of exec_UPDATEquery().
+       * Fixed parseFieldDef() t3lib_sqlparser to allow datatypes
+       with just a trailing comma (like in "tyinytext," as opposed
+       to "varchar(19)". This prevented installation of some
+       extensions.
+       * Fixed bug #2072.
+       * Fixed bug #1206.
+       * Fixed a bug with error logging and array queries (BLOB).
+       * Prepared a fix for bug #1649, pending core list approval.
+       * Fixed a bug in t3lib_page, getMultipleGroupsWhereClause()
+       where double quotes were used to quote a literal for use in
+       SQL. THIS IS MYSQL-ONLY! NEVER DO THIS! ALWAYS USE SINGLE
+       QUOTES! 
+
+2005-06-07  Karsten Dambekalns <karsten@typo3.org>
+
+       Documentation update.
+
+2005-05-19  Karsten Dambekalns <karsten@typo3.org>
+
+       Committed changes to go along with the library removal done
+       earlier. Completed debug logging.
+
+2005-02-07  Karsten Dambekalns <karsten@typo3.org>
+
+       Bringing the DBAL extension AS OF JANUARY 2005 into CVS.  Works
+       pretty well, but still needs more work. A few optimizations are
+       planned and some bugs in native mode need to be fixed. Checking
+       this in is (similar to yesterday's commit) more for
+       historic/archival reasons.  This version will NOT work with 3.7.x.
+       You have been warned.
+
+2005-02-06  Karsten Dambekalns <karsten@typo3.org>
+
+       Bringing the DBAL extension AS OF JULY 2004 into CVS. This is
+       rather for historic purposes, more changes will follow in the near
+       future.  This version was already a huge step forward, but it will
+       not work as expected with 3.7.x or 3.8.x. You have been warned.
+
+2004-03-28  Kasper Skaarhoej <kasperYYYY@typo3.com>
+
+       Initial revision
diff --git a/typo3/sysext/dbal/class.ux_t3lib_db.php b/typo3/sysext/dbal/class.ux_t3lib_db.php
new file mode 100644 (file)
index 0000000..2dfe9e6
--- /dev/null
@@ -0,0 +1,2486 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2004 Kasper Skaarhoj (kasper@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!
+***************************************************************/
+/**
+ * Contains a database abstraction layer class for TYPO3
+ *
+ * $Id$
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Karsten Dambekalns <k.dambekalns@fishfarm.de>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *  123: class ux_t3lib_DB extends t3lib_DB
+ *  169:     function ux_t3lib_DB()
+ *  184:     function initInternalVariables()
+ *
+ *              SECTION: Query Building (Overriding parent methods)
+ *  217:     function exec_INSERTquery($table,$fields_values)
+ *  275:     function exec_UPDATEquery($table,$where,$fields_values)
+ *  334:     function exec_DELETEquery($table,$where)
+ *  387:     function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')
+ *
+ *              SECTION: Creates an INSERT SQL-statement for $table from the array with field/value pairs $fields_values.
+ *  533:     function SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')
+ *  556:     function quoteSelectFields(&$select_fields)
+ *  573:     function quoteFromTables(&$from_table)
+ *  595:     function quoteWhereClause(&$where_clause)
+ *  620:     function quoteGroupBy(&$groupBy)
+ *  637:     function quoteOrderBy(&$orderBy)
+ *
+ *              SECTION: Various helper functions
+ *  663:     function quoteStr($str, $table)
+ *
+ *              SECTION: SQL wrapper functions (Overriding parent methods)
+ *  707:     function sql_error()
+ *  734:     function sql_num_rows(&$res)
+ *  760:     function sql_fetch_assoc(&$res)
+ *  808:     function sql_fetch_row(&$res)
+ *  842:     function sql_free_result(&$res)
+ *  868:     function sql_insert_id()
+ *  893:     function sql_affected_rows()
+ *  919:     function sql_data_seek(&$res,$seek)
+ *  946:     function sql_field_type(&$res,$pointer)
+ *
+ *              SECTION: Legacy functions, bound to _DEFAULT handler. (Overriding parent methods)
+ *  987:     function sql($db,$query)
+ *  999:     function sql_query($query)
+ * 1035:     function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)
+ * 1055:     function sql_select_db($TYPO3_db)
+ *
+ *              SECTION: SQL admin functions
+ * 1086:     function admin_get_tables()
+ * 1149:     function admin_get_fields($tableName)
+ * 1210:     function admin_get_keys($tableName)
+ * 1270:     function admin_query($query)
+ *
+ *              SECTION: Handler management
+ * 1333:     function handler_getFromTableList($tableList)
+ * 1379:     function handler_init($handlerKey)
+ *
+ *              SECTION: Table/Field mapping
+ * 1488:     function map_needMapping($tableList,$fieldMappingOnly=FALSE)
+ * 1524:     function map_assocArray($input,$tables,$rev=FALSE)
+ * 1573:     function map_remapSELECTQueryParts(&$select_fields,&$from_table,&$where_clause,&$groupBy,&$orderBy)
+ * 1615:     function map_sqlParts(&$sqlPartArray, $defaultTable)
+ * 1650:     function map_genericQueryParsed(&$parsedQuery)
+ * 1717:     function map_fieldNamesInArray($table,&$fieldArray)
+ *
+ *              SECTION: Debugging
+ * 1758:     function debugHandler($function,$execTime,$inData)
+ * 1823:     function debug_log($query,$ms,$data,$join,$errorFlag)
+ * 1849:     function debug_explain($query)
+ *
+ * TOTAL FUNCTIONS: 41
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+
+
+
+
+
+
+
+
+require_once(PATH_t3lib.'class.t3lib_sqlengine.php');
+require_once(PATH_t3lib.'class.t3lib_install.php');
+//require_once(t3lib_extMgm::extPath('install').'mod/class.tx_install.php');
+
+/**
+ * TYPO3 database abstraction layer
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Karsten Dambekalns <k.dambekalns@fishfarm.de>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class ux_t3lib_DB extends t3lib_DB {
+
+  // Internal, static:
+  var $printErrors = FALSE;                    // Enable output of SQL errors after query executions. Set through TYPO3_CONF_VARS, see init()
+  var $debug = FALSE;                                  // Enable debug mode. Set through TYPO3_CONF_VARS, see init()
+  var $conf = array();                         // Configuration array, copied from TYPO3_CONF_VARS in constructor.
+
+  var $mapping = array();                              // See manual.
+  var $table2handlerKeys = array();    // See manual.
+  var $handlerCfg = array (                    // See manual.
+  '_DEFAULT' => array (
+  'type' => 'native',
+  'config' => array(
+  'username' => '',            // Set by default (overridden)
+  'password' => '',            // Set by default (overridden)
+  'host' => '',                        // Set by default (overridden)
+  'database' => '',            // Set by default (overridden)
+  'driver' => '',                      // ONLY "adodb" type; eg. "mysql"
+  )
+  ),
+  );
+
+
+  // Internal, dynamic:
+  var $handlerInstance = array();                              // Contains instance of the handler objects as they are created. Exception is the native mySQL calls which are registered as an array with keys "handlerType" = "native" and "link" pointing to the link resource for the connection.
+  var $lastHandlerKey = '';                                    // Storage of the handler key of last ( SELECT) query - used for subsequent fetch-row calls etc.
+  var $lastQuery = '';                                         // Storage of last SELECT query
+  var $lastParsedAndMappedQueryArray=array();  // Query array, the last one parsed
+
+  var $resourceIdToTableNameMap = array();     // Mapping of resource ids to table names.
+
+  // Internal, caching:
+  var $cache_handlerKeyFromTableList = array();                        // Caching handlerKeys for table lists
+  var $cache_mappingFromTableList = array();                   // Caching mapping information for table lists
+  var $cache_autoIncFields = array(); // parsed SQL from standard DB dump file
+  var $cache_fieldType = array(); // field types for tables/fields
+  var $cache_primaryKeys = array(); // primary keys
+
+
+
+
+
+  /**
+        * Constructor.
+        * Creates SQL parser object and imports configuration from $TYPO3_CONF_VARS['EXTCONF']['dbal']
+        *
+        * @return      void
+        */
+  function ux_t3lib_DB()       {
+
+    // Set SQL parser object for internal use:
+    $this->SQLparser = t3lib_div::makeInstance('t3lib_sqlengine');
+    $this->Installer = t3lib_div::makeInstance('t3lib_install');
+
+    // Set internal variables with configuration:
+    $this->conf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'];
+    $this->initInternalVariables();
+  }
+
+  /**
+        * Setting internal variables from $this->conf
+        *
+        * @return      void
+        */
+  function initInternalVariables()     {
+
+    // Set outside configuration:
+    if (isset($this->conf['mapping']))                         $this->mapping = $this->conf['mapping'];
+    if (isset($this->conf['table2handlerKeys']))       $this->table2handlerKeys = $this->conf['table2handlerKeys'];
+    if (isset($this->conf['handlerCfg']))                      $this->handlerCfg = $this->conf['handlerCfg'];
+
+    $this->cacheFieldInfo();
+    // Debugging settings:
+    $this->printErrors = $this->conf['debugOptions']['printErrors'] ? TRUE : FALSE;
+    $this->debug = $this->conf['debugOptions']['enabled'] ? TRUE : FALSE;
+  }
+
+  function clearCachedFieldInfo() {
+    if(file_exists(PATH_typo3conf.'temp_fieldInfo.php'))
+    unlink(PATH_typo3conf.'temp_fieldInfo.php');
+  }
+
+  function cacheFieldInfo() {
+    global $TYPO3_LOADED_EXT;
+    $extSQL = '';
+    $parsedExtSQL = array();
+
+    // try to fetch cached file first
+    // file is removed when admin_query() is called
+    if(file_exists(PATH_typo3conf.'temp_fieldInfo.php')) {
+      $fdata = unserialize(t3lib_div::getUrl(PATH_typo3conf.'temp_fieldInfo.php'));
+      $this->cache_autoIncFields = $fdata['incFields'];
+      $this->cache_fieldType = $fdata['fieldTypes'];
+      $this->cache_primaryKeys = $fdata['primaryKeys'];
+    }
+    else {
+      // handle stddb.sql
+      $extSQL = t3lib_div::getUrl(PATH_site.'t3lib/stddb/tables.sql');
+      $parsedExtSQL = $this->Installer->getFieldDefinitions_sqlContent($extSQL);
+
+      // extract auto_inc field (if any)
+      foreach($parsedExtSQL as $table => $tdef) {
+        foreach($tdef['fields'] as $field => $fdef) {
+          $fdef = $this->SQLparser->parseFieldDef($fdef);
+          $this->cache_fieldType[$table][$field]['type'] = $fdef['fieldType'];
+          $this->cache_fieldType[$table][$field]['metaType'] = $this->MySQLMetaType($fdef['fieldType']);
+          $this->cache_fieldType[$table][$field]['notnull'] = (isset($fdef['featureIndex']['NOTNULL']) && !$this->SQLparser->checkEmptyDefaultValue($fdef['featureIndex'])) ? 1 : 0;
+          if(isset($fdef['featureIndex']['AUTO_INCREMENT'])) {
+            // store in array
+            $this->cache_autoIncFields[$table] = $field;
+          }
+          if(isset($tdef['keys']['PRIMARY'])) {
+                                               $this->cache_primaryKeys[$table] = substr($tdef['keys']['PRIMARY'], 13, -1);
+          }
+        }
+      }
+
+      // loop over all installed extensions
+      foreach($TYPO3_LOADED_EXT as $ext => $v) {
+        if(!is_array($v) || !isset($v['ext_tables.sql']))
+        continue;
+
+        // fetch db dump (if any) and parse it
+        $extSQL = t3lib_div::getUrl($v['ext_tables.sql']);
+        $parsedExtSQL = $this->Installer->getFieldDefinitions_sqlContent($extSQL);
+
+        // extract auto_inc field (if any)
+        foreach($parsedExtSQL as $table => $tdef) {
+          foreach($tdef['fields'] as $field => $fdef) {
+            $fdef = $this->SQLparser->parseFieldDef($fdef);
+            $this->cache_fieldType[$table][$field]['type'] = $fdef['fieldType'];
+            $this->cache_fieldType[$table][$field]['metaType'] = $this->MySQLMetaType($fdef['fieldType']);
+            $this->cache_fieldType[$table][$field]['notnull'] = (isset($fdef['featureIndex']['NOTNULL']) && !$this->SQLparser->checkEmptyDefaultValue($fdef['featureIndex'])) ? 1 : 0;
+            if(isset($fdef['featureIndex']['AUTO_INCREMENT'])) {
+              $this->cache_autoIncFields[$table] = $field;
+            }
+            if(isset($tdef['keys']['PRIMARY'])) {
+                                                       $this->cache_primaryKeys[$table] = substr($tdef['keys']['PRIMARY'], 13, -1);
+            }
+          }
+        }
+      }
+
+                       $cachedFieldInfo = array('incFields' => $this->cache_autoIncFields, 'fieldTypes' => $this->cache_fieldType, 'primaryKeys' => $this->cache_primaryKeys);
+                       $cachedFieldInfo = serialize($this->mapCachedFieldInfo($cachedFieldInfo));
+
+      // write serialized content to file
+                       t3lib_div::writeFile(PATH_typo3conf."temp_fieldInfo.php", $cachedFieldInfo);
+
+                       if (strcmp(t3lib_div::getUrl(PATH_typo3conf."temp_fieldInfo.php"), $cachedFieldInfo))   {
+        die('typo3temp/temp_incfields.php was NOT updated properly (written content didn\'t match file content) - maybe write access problem?');
+      }
+    }
+  }
+
+       /**
+       * This function builds all definitions for mapped tables and fields
+       * @see cacheFieldInfo()
+       */
+       function mapCachedFieldInfo($fieldInfo){
+               global $TYPO3_CONF_VARS;
+
+               foreach($TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] as $mappedTable => $mappedConf){
+                       if(array_key_exists($mappedTable, $fieldInfo['incFields'])) {
+                               $mappedTableAlias = $mappedConf['mapTableName'];
+                               $fieldInfo['incFields'][$mappedTableAlias] = isset($mappedConf['mapFieldNames'][$fieldInfo['incFields'][$mappedTable]]) ? $mappedConf['mapFieldNames'][$fieldInfo['incFields'][$mappedTable]] : $fieldInfo['incFields'][$mappedTable];
+                       }
+
+                       if(array_key_exists($mappedTable, $fieldInfo['fieldTypes'])) {
+                               foreach($fieldInfo['fieldTypes'][$mappedTable] as $field => $fieldConf){
+                                       $tempMappedFieldConf[$mappedConf['mapFieldNames'][$field]] = $fieldConf;
+                               }
+
+                               $fieldInfo['fieldTypes'][$mappedConf['mapTableName']] = $tempMappedFieldConf;
+                       }
+
+                       if(array_key_exists($mappedTable, $fieldInfo['primaryKeys'])) {
+                               $mappedTableAlias = $mappedConf['mapTableName'];
+                               $fieldInfo['primaryKeys'][$mappedTableAlias] = isset($mappedConf['mapFieldNames'][$fieldInfo['primaryKeys'][$mappedTable]]) ? $mappedConf['mapFieldNames'][$fieldInfo['primaryKeys'][$mappedTable]] : $fieldInfo['primaryKeys'][$mappedTable];
+                       }
+
+               }
+
+               return $fieldInfo;
+       }
+
+
+  /************************************
+  *
+  * Query Building (Overriding parent methods)
+  * These functions are extending counterparts in the parent class.
+  *
+  **************************************/
+
+  /* From the ADOdb documentation, this is what we do (_Execute for SELECT, _query for the other actions)
+
+  Execute() is the default way to run queries. You can use the low-level functions _Execute() and _query() to reduce query overhead.
+  Both these functions share the same parameters as Execute().
+
+  If you do not have any bind parameters or your database supports binding (without emulation), then you can call _Execute() directly.
+  Calling this function bypasses bind emulation. Debugging is still supported in _Execute().
+
+  If you do not require debugging facilities nor emulated binding, and do not require a recordset to be returned, then you can call _query.
+  This is great for inserts, updates and deletes. Calling this function bypasses emulated binding, debugging, and recordset handling. Either
+  the resultid, true or false are returned by _query().
+  */
+
+  /**
+        * Inserts a record for $table from the array with field/value pairs $fields_values.
+        *
+        * @param       string          Table name
+        * @param       array           Field values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$insertFields" with 'fieldname'=>'value' and pass it to this function as argument.
+        * @return      mixed           Result from handler, usually TRUE when success and FALSE on failure
+        */
+  function exec_INSERTquery($table,$fields_values)     {
+
+    if ($this->debug)  $pt = t3lib_div::milliseconds();
+
+    // Do field mapping if needed:
+    $ORIG_tableName = $table;
+    if ($tableArray = $this->map_needMapping($table))  {
+
+      // Field mapping of array:
+      $fields_values = $this->map_assocArray($fields_values,$tableArray);
+
+      // Table name:
+      if ($this->mapping[$table]['mapTableName'])      {
+        $table = $this->mapping[$table]['mapTableName'];
+      }
+    }
+    // Select API:
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $this->lastQuery = $this->INSERTquery($table,$fields_values);
+      if(is_string($this->lastQuery)) {
+        $sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      }
+      else {
+        $sqlResult = mysql_query($this->lastQuery[0], $this->handlerInstance[$this->lastHandlerKey]['link']);
+        foreach($this->lastQuery[1] as $field => $content) {
+          mysql_query('UPDATE '.$this->quoteFromTables($table).' SET '.$this->quoteFromTables($field).'='.$this->fullQuoteStr($content,$table).' WHERE '.$this->quoteWhereClause($where), $this->handlerInstance[$this->lastHandlerKey]['link']);
+        }
+      }
+      break;
+      case 'adodb':
+      // auto generate ID for auto_increment fields if not present (static import needs this!)
+      // should we check the table name here (static_*)?
+      if(isset($this->cache_autoIncFields[$table])) {
+        if(isset($fields_values[$this->cache_autoIncFields[$table]])) {
+          $new_id = $fields_values[$this->cache_autoIncFields[$table]];
+          if($table !== 'tx_dbal_debuglog') {
+            $this->handlerInstance[$this->lastHandlerKey]->last_insert_id = $new_id;
+          }
+        }
+        else {
+          $new_id = $this->handlerInstance[$this->lastHandlerKey]->GenID($table.'_'.$this->cache_autoIncFields[$table]);
+          $fields_values[$this->cache_autoIncFields[$table]] = $new_id;
+          if($table !== 'tx_dbal_debuglog') {
+            $this->handlerInstance[$this->lastHandlerKey]->last_insert_id = $new_id;
+          }
+        }
+      }
+
+      $this->lastQuery = $this->INSERTquery($table,$fields_values);
+      if(is_string($this->lastQuery)) {
+        $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery,false);
+      }
+      else {
+       $this->handlerInstance[$this->lastHandlerKey]->StartTrans();
+        $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery[0],false);
+        foreach($this->lastQuery[1] as $field => $content) {
+          if(empty($content)) continue;
+
+          if(isset($this->cache_autoIncFields[$table]) && isset($new_id)) {
+            $this->handlerInstance[$this->lastHandlerKey]->UpdateBlob($this->quoteFromTables($table),$field,$content,$this->quoteWhereClause($this->cache_autoIncFields[$table].'='.$new_id));
+          }
+          elseif(isset($this->cache_primaryKeys[$table])) {
+            $pks = explode(',', $this->cache_primaryKeys[$table]);
+            foreach ($pks as $pk) {
+              if(isset($fields_values[$pk]))
+              $where .= $pk.'='.$this->fullQuoteStr($fields_values[$pk], $table).' AND ';
+            }
+            $where = $this->quoteWhereClause($where.'1=1');
+            $this->handlerInstance[$this->lastHandlerKey]->UpdateBlob($this->quoteFromTables($table),$field,$content,$where);
+          }
+          else {
+                       $this->handlerInstance[$this->lastHandlerKey]->CompleteTrans(false);
+            die('Could not update BLOB >>>> no WHERE clause found!'); // should never ever happen
+          }
+        }
+               $this->handlerInstance[$this->lastHandlerKey]->CompleteTrans();
+      }
+      break;
+      case 'userdefined':
+      $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->exec_INSERTquery($table,$fields_values);
+      break;
+    }
+
+    // Print errors:
+    if ($this->printErrors && $this->sql_error())      { debug(array($this->sql_error()));     }
+
+    # DEBUG:
+    if ($this->debug)  {
+      $this->debugHandler(
+      'exec_INSERTquery',
+      t3lib_div::milliseconds()-$pt,
+      array(
+      'handlerType' => $hType,
+      'args' => array($table,$fields_values),
+      'ORIG_tablename' => $ORIG_tableName
+      )
+      );
+    }
+    // Return output:
+    return $sqlResult;
+  }
+
+  /**
+        * Updates a record from $table
+        *
+        * @param       string          Database tablename
+        * @param       string          WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
+        * @param       array           Field values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$updateFields" with 'fieldname'=>'value' and pass it to this function as argument.
+        * @return      mixed           Result from handler, usually TRUE when success and FALSE on failure
+        */
+  function exec_UPDATEquery($table,$where,$fields_values)      {
+
+    if ($this->debug)  $pt = t3lib_div::milliseconds();
+
+    // Do table/field mapping:
+    $ORIG_tableName = $table;
+    if ($tableArray = $this->map_needMapping($table))  {
+
+      // Field mapping of array:
+      $fields_values = $this->map_assocArray($fields_values,$tableArray);
+
+      // Where clause table and field mapping:
+      $whereParts = $this->SQLparser->parseWhereClause($where);
+      $this->map_sqlParts($whereParts,$tableArray[0]['table']);
+      $where = $this->SQLparser->compileWhereClause($whereParts);
+
+      // Table name:
+      if ($this->mapping[$table]['mapTableName'])      {
+        $table = $this->mapping[$table]['mapTableName'];
+      }
+    }
+
+    // Select API
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $this->lastQuery = $this->UPDATEquery($table,$where,$fields_values);
+      if(is_string($this->lastQuery)) {
+        $sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      }
+      else {
+        $sqlResult = mysql_query($this->lastQuery[0], $this->handlerInstance[$this->lastHandlerKey]['link']);
+        foreach($this->lastQuery[1] as $field => $content) {
+          mysql_query('UPDATE '.$this->quoteFromTables($table).' SET '.$this->quoteFromTables($field).'='.$this->fullQuoteStr($content,$table).' WHERE '.$this->quoteWhereClause($where), $this->handlerInstance[$this->lastHandlerKey]['link']);
+        }
+      }
+      break;
+      case 'adodb':
+      $this->lastQuery = $this->UPDATEquery($table,$where,$fields_values);
+      if(is_string($this->lastQuery)) {
+             $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery,false);
+      } else {
+               $this->handlerInstance[$this->lastHandlerKey]->StartTrans();
+        $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery[0],false);
+        foreach($this->lastQuery[1] as $field => $content) {
+          $this->handlerInstance[$this->lastHandlerKey]->UpdateBlob($this->quoteFromTables($table),$field,$content,$this->quoteWhereClause($where));
+        }
+               $this->handlerInstance[$this->lastHandlerKey]->CompleteTrans();
+      }
+      break;
+      case 'userdefined':
+      $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->exec_UPDATEquery($table,$where,$fields_values);
+      break;
+    }
+
+    // Print errors:
+    if ($this->printErrors && $this->sql_error())      { debug(array($this->sql_error()));     }
+
+    # DEBUG:
+    if ($this->debug)  {
+      $this->debugHandler(
+      'exec_UPDATEquery',
+      t3lib_div::milliseconds()-$pt,
+      array(
+      'handlerType' => $hType,
+      'args' => array($table,$where, $fields_values),
+      'ORIG_from_table' => $ORIG_tableName
+      )
+      );
+    }
+
+    // Return result:
+    return $sqlResult;
+  }
+
+  /**
+        * Deletes records from table
+        *
+        * @param       string          Database tablename
+        * @param       string          WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
+        * @return      mixed           Result from handler
+        */
+  function exec_DELETEquery($table,$where)     {
+
+    if ($this->debug)  $pt = t3lib_div::milliseconds();
+
+    // Do table/field mapping:
+    $ORIG_tableName = $table;
+    if ($tableArray = $this->map_needMapping($table))  {
+
+      // Where clause:
+      $whereParts = $this->SQLparser->parseWhereClause($where);
+      $this->map_sqlParts($whereParts,$tableArray[0]['table']);
+      $where = $this->SQLparser->compileWhereClause($whereParts);
+
+      // Table name:
+      if ($this->mapping[$table]['mapTableName'])      {
+        $table = $this->mapping[$table]['mapTableName'];
+      }
+    }
+
+    // Select API
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $this->lastQuery = $this->DELETEquery($table,$where);
+      $sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      break;
+      case 'adodb':
+      $this->lastQuery = $this->DELETEquery($table,$where);
+      $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery,false);
+      break;
+      case 'userdefined':
+      $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->exec_DELETEquery($table,$where);
+      break;
+    }
+
+    // Print errors:
+    if ($this->printErrors && $this->sql_error())      { debug(array($this->sql_error()));     }
+
+    # DEBUG:
+    if ($this->debug)  {
+      $this->debugHandler(
+      'exec_DELETEquery',
+      t3lib_div::milliseconds()-$pt,
+      array(
+      'handlerType' => $hType,
+      'args' => array($table,$where),
+      'ORIG_from_table' => $ORIG_tableName
+      )
+      );
+    }
+
+    // Return result:
+    return $sqlResult;
+  }
+
+  /**
+        * Selects records from Data Source
+        *
+        * @param       string $select_fields List of fields to select from the table. This is what comes right after "SELECT ...". Required value.
+        * @param       string $from_table Table(s) from which to select. This is what comes right after "FROM ...". Required value.
+        * @param       string $where_clause Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQquoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
+        * @param       string $groupBy Optional GROUP BY field(s), if none, supply blank string.
+        * @param       string $orderBy Optional ORDER BY field(s), if none, supply blank string.
+        * @param       string $limit Optional LIMIT value ([begin,]max), if none, supply blank string.
+        * @return      mixed           Result from handler. Typically object from DBAL layers.
+        */
+  function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')        {
+
+    if ($this->debug)  $pt = t3lib_div::milliseconds();
+
+    // Map table / field names if needed:
+    $ORIG_tableName = $from_table;     // Saving table names in $ORIG_from_table since $from_table is transformed beneath:
+    if ($tableArray = $this->map_needMapping($ORIG_tableName)) {
+      $this->map_remapSELECTQueryParts($select_fields,$from_table,$where_clause,$groupBy,$orderBy);    // Variables passed by reference!
+    }
+
+    // Get handler key and select API:
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    $hType = (string)$this->handlerCfg[$this->lastHandlerKey]['type'];
+    switch($hType)     {
+      case 'native':
+      $this->lastQuery = $this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
+      $sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      $this->resourceIdToTableNameMap[(string)$sqlResult] = $ORIG_tableName;
+      break;
+      case 'adodb':
+      if ($limit)      {
+        $splitLimit = t3lib_div::intExplode(',',$limit);               // Splitting the limit values:
+        if ($splitLimit[1])    {       // If there are two parameters, do mapping differently than otherwise:
+        $numrows = $splitLimit[1];
+        $offset = $splitLimit[0];
+        } else {
+          $numrows = $splitLimit[0];
+          $offset = 0;
+        }
+
+                               $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->SelectLimit($this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy), $numrows, $offset);
+        $this->lastQuery = $sqlResult->sql;
+      } else {
+        $this->lastQuery = $this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
+        $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_Execute($this->lastQuery);
+      }
+      $sqlResult->TYPO3_DBAL_handlerType = 'adodb';    // Setting handler type in result object (for later recognition!)
+      $sqlResult->TYPO3_DBAL_tableList = $ORIG_tableName;
+      break;
+      case 'userdefined':
+      $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
+      if (is_object($sqlResult))       {
+        $sqlResult->TYPO3_DBAL_handlerType = 'userdefined';    // Setting handler type in result object (for later recognition!)
+        $sqlResult->TYPO3_DBAL_tableList = $ORIG_tableName;
+      }
+      break;
+    }
+
+    // Print errors:
+    if ($this->printErrors && $this->sql_error())      { debug(array($this->sql_error()));     }
+
+    # DEBUG:
+    if ($this->debug)  {
+      $this->debugHandler(
+      'exec_SELECTquery',
+      t3lib_div::milliseconds()-$pt,
+      array(
+      'handlerType' => $hType,
+      'args' => array($from_table,$select_fields,$where_clause,$groupBy,$orderBy,$limit),
+      'ORIG_from_table' => $ORIG_tableName
+      )
+      );
+    }
+
+    // Return result handler.
+    return $sqlResult;
+  }
+
+
+
+  /**************************************
+  *
+  * Query building
+  *
+  **************************************/
+
+  /**
+        * Creates an INSERT SQL-statement for $table from the array with field/value pairs $fields_values.
+        * Usage count/core: 4
+        *
+        * @param       string          See exec_INSERTquery()
+        * @param       array           See exec_INSERTquery()
+        * @return      string          Full SQL query for INSERT (unless $fields_values does not contain any elements in which case it will be false)
+        * @depreciated                 use exec_INSERTquery() instead if possible!
+        */
+  function INSERTquery($table,$fields_values)  {
+    // Table and fieldnames should be "SQL-injection-safe" when supplied to this function (contrary to values in the arrays which may be insecure).
+    if (is_array($fields_values) && count($fields_values))     {
+      $blobfields = array();
+      $nArr = array();
+      foreach($fields_values as $k => $v)      {
+        if($this->sql_field_metatype($table,$k) == 'B') {
+          /* // is this really needed for Oracle?
+          if($this->handlerInstance[$this->lastHandlerKey]->databaseType == 'oci8')
+                                       $nArr[$this->quoteFieldNames($k)] = 'empty_blob()';
+          else
+                                       $nArr[$this->quoteFieldNames($k)] = 'null';
+          */
+                                       $nArr[$this->quoteFieldNames($k)] = 'null';
+                                       $blobfields[$this->quoteFieldNames($k)] = $v;
+        }
+        else {
+          // Add slashes old-school:
+          // cast numerical values
+          $mt = $this->sql_field_metatype($table,$k);
+          $v = (($mt{0}=='I')||($mt{0}=='F')) ? (int)$v : $v;
+
+                                       $nArr[$this->quoteFieldNames($k)] = $this->fullQuoteStr($v, $table);
+        }
+      }
+      if(((string)$this->handlerCfg[$this->lastHandlerKey]['type']!=='native') && count($blobfields)) {
+        $query[0] = 'INSERT INTO '.$this->quoteFromTables($table).'
+                               (
+                                       '.implode(',
+                                       ',array_keys($nArr)).'
+                               ) VALUES (
+                                       '.implode(',
+                                       ',$nArr).'
+                               )';
+        $query[1] = $blobfields;
+        if ($this->debugOutput) $this->debug_lastBuiltQuery = $query[0];
+      }
+      else {
+        $query = 'INSERT INTO '.$this->quoteFromTables($table).'
+                               (
+                                       '.implode(',
+                                       ',array_keys($nArr)).'
+                               ) VALUES (
+                                       '.implode(',
+                                       ',$nArr).'
+                               )';
+
+        if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;
+      }
+
+      return $query;
+    }
+  }
+
+  /**
+        * Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values.
+        * Usage count/core: 6
+        *
+        * @param       string          See exec_UPDATEquery()
+        * @param       string          See exec_UPDATEquery()
+        * @param       array           See exec_UPDATEquery()
+        * @return      string          Full SQL query for UPDATE (unless $fields_values does not contain any elements in which case it will be false)
+        * @depreciated                 use exec_UPDATEquery() instead if possible!
+        */
+  function UPDATEquery($table,$where,$fields_values)   {
+    // Table and fieldnames should be "SQL-injection-safe" when supplied to this function (contrary to values in the arrays which may be insecure).
+    if (is_string($where))     {
+      if (is_array($fields_values) && count($fields_values))   {
+        $blobfields = array();
+        $nArr = array();
+        foreach($fields_values as $k => $v)    {
+          if($this->sql_field_metatype($table,$k) == 'B') {
+            // do we need empty_blob() for Oracle? see also INSERTquery()
+                                               $nArr[] = $this->quoteFieldNames($k).'=NULL';
+                                               $blobfields[$this->quoteFieldNames($k)] = $v;
+          }
+          else {
+            // Add slashes old-school:
+            // cast numeric values
+            $mt = $this->sql_field_metatype($table,$k);
+            $v = (($mt{0}=='I')||($mt{0}=='F')) ? (int)$v : $v;
+                                               $nArr[] = $this->quoteFieldNames($k).'='.$this->fullQuoteStr($v, $table);
+          }
+        }
+      }
+
+      if(count($blobfields)) {
+        $query[0] = 'UPDATE '.$this->quoteFromTables($table).'
+                                       SET
+                                               '.implode(',
+                                               ',$nArr).
+        (strlen($where)>0 ? '
+                                       WHERE
+                                               '.$this->quoteWhereClause($where) : '');
+        $query[1] = $blobfields;
+        if ($this->debugOutput) $this->debug_lastBuiltQuery = $query[0];
+      }
+      else {
+        $query = 'UPDATE '.$this->quoteFromTables($table).'
+                                       SET
+                                               '.implode(',
+                                               ',$nArr).
+        (strlen($where)>0 ? '
+                                       WHERE
+                                               '.$this->quoteWhereClause($where) : '');
+
+        if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;
+      }
+
+      return $query;
+    }
+    else {
+      die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for UPDATE query was not a string in $this->UPDATEquery() !');
+    }
+  }
+
+  /**
+        * Creates a DELETE SQL-statement for $table where $where-clause
+        * Usage count/core: 3
+        *
+        * @param       string          See exec_DELETEquery()
+        * @param       string          See exec_DELETEquery()
+        * @return      string          Full SQL query for DELETE
+        * @depreciated                 use exec_DELETEquery() instead if possible!
+        */
+  function DELETEquery($table,$where)  {
+    if (is_string($where))     {
+      $table = $this->quoteFromTables($table);
+      $where = $this->quoteWhereClause($where);
+
+      $query = parent::DELETEquery($table, $where);
+
+      if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;
+      return $query;
+    } else {
+      die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for DELETE query was not a string in $this->DELETEquery() !');
+    }
+  }
+
+  /**
+        * Creates a SELECT SQL-statement
+        * Usage count/core: 11
+        *
+        * @param       string          See exec_SELECTquery()
+        * @param       string          See exec_SELECTquery()
+        * @param       string          See exec_SELECTquery()
+        * @param       string          See exec_SELECTquery()
+        * @param       string          See exec_SELECTquery()
+        * @param       string          See exec_SELECTquery()
+        * @return      string          Full SQL query for SELECT
+        * @depreciated                 use exec_SELECTquery() instead if possible!
+        */
+  function SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')     {
+
+               $select_fields = $this->quoteFieldNames($select_fields);
+    $from_table = $this->quoteFromTables($from_table);
+    $where_clause = $this->quoteWhereClause($where_clause);
+    $groupBy = $this->quoteGroupBy($groupBy);
+    $orderBy = $this->quoteOrderBy($orderBy);
+
+    // call parent method to build actual query
+    $query = parent::SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
+
+    if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;
+
+    return $query;
+  }
+
+
+  /**************************************
+  *
+  * Functions for quoting table/field names
+  *
+  **************************************/
+
+  /**
+        * Quotes field (and table) names with the quote character suitable for the DB being used
+        * Use quoteFieldNames instead!
+        *
+        * @param       string          List of fields to be selected from DB
+        * @return      string          Quoted list of fields to be selected from DB
+        * @deprecated
+        */
+  function quoteSelectFields($select_fields) {
+               $this->quoteFieldNames($select_fields);
+       }
+
+       /**
+        * Quotes field (and table) names with the quote character suitable for the DB being used
+        *
+        * @param       string          List of fields to be used in query to DB
+        * @return      string          Quoted list of fields to be in query to DB
+        */
+       function quoteFieldNames($select_fields) {
+    if($select_fields == '') return '';
+
+    $select_fields = $this->SQLparser->parseFieldList($select_fields);
+    foreach($select_fields as $k => $v)        {
+      if($select_fields[$k]['field'] != '' && $select_fields[$k]['field'] != '*') {
+        $select_fields[$k]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$select_fields[$k]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+      if($select_fields[$k]['table'] != '') {
+        $select_fields[$k]['table'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$select_fields[$k]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+      if($select_fields[$k]['as'] != '') {
+        $select_fields[$k]['as'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$select_fields[$k]['as'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+      if(isset($select_fields[$k]['func_content.']) && $select_fields[$k]['func_content.'][0]['func_content'] != '*'){
+        if(strstr($select_fields[$k]['func_content.'][0]['func_content'],'.')) {
+                                       $select_fields[$k]['func_content.'][0]['func_content'] = $this->quoteFieldNames($select_fields[$k]['func_content.'][0]['func_content']);
+                                       $select_fields[$k]['func_content'] = $this->quoteFieldNames($select_fields[$k]['func_content']);
+        }
+        else {
+          $select_fields[$k]['func_content.'][0]['func_content'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$select_fields[$k]['func_content.'][0]['func_content'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+          $select_fields[$k]['func_content'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$select_fields[$k]['func_content'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+        }
+      }
+    }
+
+    return $this->SQLparser->compileFieldList($select_fields);
+  }
+
+  /**
+        * Quotes table names with the quote character suitable for the DB being used
+        *
+        * @param       string          List of tables to be selected from DB
+        * @return      string          Quoted list of tables to be selected from DB
+        */
+  function quoteFromTables($from_table) {
+    if($from_table == '') return '';
+
+    $from_table = $this->SQLparser->parseFromTables($from_table);
+    foreach($from_table as $k => $v)   {
+      $from_table[$k]['table'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      if($from_table[$k]['as'] != '') {
+        $from_table[$k]['as'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['as'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+      if (is_array($v['JOIN']))        {
+        $from_table[$k]['JOIN']['withTable'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['JOIN']['withTable'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+        $from_table[$k]['JOIN']['ON'][0]['table'] = ($from_table[$k]['JOIN']['ON'][0]['table']) ? $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['JOIN']['ON'][0]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote : '';
+        $from_table[$k]['JOIN']['ON'][0]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['JOIN']['ON'][0]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+        $from_table[$k]['JOIN']['ON'][1]['table'] = ($from_table[$k]['JOIN']['ON'][1]['table']) ? $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['JOIN']['ON'][1]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote : '';
+        $from_table[$k]['JOIN']['ON'][1]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$from_table[$k]['JOIN']['ON'][1]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+    }
+    return $this->SQLparser->compileFromTables($from_table);
+  }
+
+  /**
+        * Quotes the field (and table) names within a where clause with the quote character suitable for the DB being used
+        *
+        * @param       string          A where clause that can e parsed by parseWhereClause
+        * @return      string          Usable where clause with quoted field/table names
+        */
+  function quoteWhereClause($where_clause) {
+    if($where_clause == '') return '';
+
+    $where_clause = $this->SQLparser->parseWhereClause($where_clause);
+    $where_clause = $this->_quoteWhereClause($where_clause);
+    $where_clause = $this->SQLparser->compileWhereClause($where_clause);
+
+    return $where_clause;
+  }
+
+  /**
+        * [Describe function...]
+        *
+        * @param       [type]          $$groupBy: ...
+        * @return      [type]          ...
+        */
+  function _quoteWhereClause($where_clause) {
+    foreach($where_clause as $k => $v) {
+      // Look for sublevel:
+      if (is_array($where_clause[$k]['sub']))  {
+        $where_clause[$k]['sub'] = $this->_quoteWhereClause($where_clause[$k]['sub']);
+      } else {
+        if($where_clause[$k]['table'] != '') {
+          $where_clause[$k]['table'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$where_clause[$k]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+        }
+        if(!is_numeric($where_clause[$k]['field'])) {
+          $where_clause[$k]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$where_clause[$k]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+        }
+      }
+      if ($where_clause[$k]['comparator'])     {
+        // Detecting value type; list or plain:
+        if ((!isset($where_clause[$k]['value'][1]) || $where_clause[$k]['value'][1] == '') && is_string($where_clause[$k]['value'][0]) && strstr($where_clause[$k]['value'][0], '.') && !t3lib_div::inList('NOTIN,IN',strtoupper(str_replace(array(" ","\n","\r","\t"),'',$where_clause[$k]['comparator']))))  {
+                                       $where_clause[$k]['value'][0] = $this->quoteFieldNames($where_clause[$k]['value'][0]);
+        }
+      }
+    }
+
+    return $where_clause;
+  }
+
+  /**
+        * [Describe function...]
+        *
+        * @param       [type]          $$groupBy: ...
+        * @return      [type]          ...
+        */
+  function quoteGroupBy($groupBy) {
+    if($groupBy == '') return '';
+
+    $groupBy = $this->SQLparser->parseFieldList($groupBy);
+    foreach($groupBy as $k => $v)      {
+      $groupBy[$k]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$groupBy[$k]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      if($groupBy[$k]['table'] != '') {
+        $groupBy[$k]['table'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$groupBy[$k]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+    }
+    return $this->SQLparser->compileFieldList($groupBy);
+  }
+
+  /**
+        * [Describe function...]
+        *
+        * @param       [type]          $$orderBy: ...
+        * @return      [type]          ...
+        */
+  function quoteOrderBy($orderBy) {
+    if($orderBy == '') return '';
+
+    $orderBy = $this->SQLparser->parseFieldList($orderBy);
+    foreach($orderBy as $k => $v)      {
+      $orderBy[$k]['field'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$orderBy[$k]['field'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      if($orderBy[$k]['table'] != '') {
+        $orderBy[$k]['table'] = $this->handlerInstance[$this->lastHandlerKey]->nameQuote.$orderBy[$k]['table'].$this->handlerInstance[$this->lastHandlerKey]->nameQuote;
+      }
+    }
+    return $this->SQLparser->compileFieldList($orderBy);
+  }
+
+
+
+  /**************************************
+  *
+  * Various helper functions
+  *
+  **************************************/
+
+       /**
+        * Escaping and quoting values for SQL statements.
+        *
+        * @param       string          Input string
+        * @param       string          Table name for which to quote string. Just enter the table that the field-value is selected from (and any DBAL will look up which handler to use and then how to quote the string!).
+        * @return      string          Output string; Wrapped in single quotes and quotes in the string (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
+        * @see quoteStr()
+        */
+  function fullQuoteStr($str,$table) {
+       return '\''.$this->quoteStr($str, $table).'\'';
+  }
+
+       /**
+        * Substitution for PHP function "addslashes()"
+        * NOTICE: You must wrap the output of this function in SINGLE QUOTES to be DBAL compatible. Unless you have to apply the single quotes yourself you should rather use ->fullQuoteStr()!
+        *
+        * @param       string          Input string
+        * @param       string          Table name for which to quote string. Just enter the table that the field-value is selected from (and any DBAL will look up which handler to use and then how to quote the string!).
+        * @return      string          Output string; Quotes (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
+        * @see quoteStr()
+        */
+  function quoteStr($str, $table)      {
+    $this->lastHandlerKey = $this->handler_getFromTableList($table);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $str = mysql_real_escape_string($str, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      break;
+      case 'adodb':
+      $str = substr($this->handlerInstance[$this->lastHandlerKey]->qstr($str),1,-1);
+      break;
+      case 'userdefined':
+      $str = $this->handlerInstance[$this->lastHandlerKey]->quoteStr($str);
+      break;
+      default:
+      die('No handler found!!!');
+      break;
+    }
+
+    return $str;
+  }
+
+
+  /**
+        * Return MetaType for native field type (ADOdb only!)
+        *
+        * @param       string          native type as reported by admin_get_fields()
+        * @param       string          Table name for which query type string. Important for detection of DBMS handler of the query!
+        * @return      string          Meta type (currenly ADOdb syntax only, http://phplens.com/lens/adodb/docs-adodb.htm#metatype)
+        */
+  function MetaType($type,$table,$max_length=-1)       {
+    $this->lastHandlerKey = $this->handler_getFromTableList($table);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'adodb':
+      $rs = $this->handlerInstance[$this->lastHandlerKey]->SelectLimit('SELECT * FROM '.$this->quoteFromTables($table),1);
+      $str = $rs->MetaType($type, $max_length);
+      break;
+      default:
+      die('No handler found!!!');
+      break;
+    }
+
+    return $str;
+  }
+
+
+  /**
+        * Return MetaType for native MySQL field type
+        *
+        * @param       string          native type as reported as in mysqldump files
+        * @return      string          Meta type (currenly ADOdb syntax only, http://phplens.com/lens/adodb/docs-adodb.htm#metatype)
+        */
+  function MySQLMetaType($t) {
+
+    switch (strtoupper($t)) {
+      case 'STRING':
+      case 'CHAR':
+      case 'VARCHAR':
+      //               case 'TINYBLOB': // moved below, see there for the reason
+      //               case 'TINYTEXT': // moved below, see there for the reason
+      case 'ENUM':
+      case 'SET':
+      return 'C';
+
+      case 'TINYTEXT': // basically the same as with TINYBLOB
+      case 'TEXT':
+      case 'LONGTEXT':
+      case 'MEDIUMTEXT':
+      return 'X';
+
+      // php_mysql extension always returns 'blob' even if 'text'
+      // so we have to check whether binary...
+      case 'IMAGE':
+      case 'TINYBLOB': // this got moved here from above.
+      // otherwise tinyblob fields become varchar without length.
+      // this fails on Oracle and results in char(1) on PostgreSQL
+      case 'LONGBLOB':
+      case 'BLOB':
+      case 'MEDIUMBLOB':
+      return 'B';
+
+      case 'YEAR':
+      case 'DATE': return 'D';
+
+      case 'TIME':
+      case 'DATETIME':
+      case 'TIMESTAMP': return 'T';
+
+      case 'FLOAT':
+      case 'DOUBLE':
+      return 'F';
+
+      case 'INT':
+      case 'INTEGER': return 'I';
+      case 'TINYINT': return 'I1';
+      case 'SMALLINT': return 'I2';
+      case 'MEDIUMINT': return 'I4';
+      case 'BIGINT': return 'I8';
+
+      default: return 'N';
+    }
+  }
+
+  /**
+        * Return actual MySQL type for meta field type
+        *
+        * @param       string          Meta type (currenly ADOdb syntax only, http://phplens.com/lens/adodb/docs-adodb.htm#metatype)
+        * @return      string          native type as reported as in mysqldump files, uppercase
+        */
+  function MySQLActualType($meta) {
+    switch(strtoupper($meta)) {
+      case 'C': return 'VARCHAR';
+      case 'XL':
+      case 'X': return 'LONGTEXT';
+
+      case 'C2': return 'VARCHAR';
+      case 'X2': return 'LONGTEXT';
+
+      case 'B': return 'LONGBLOB';
+
+      case 'D': return 'DATE';
+      case 'T': return 'DATETIME';
+      case 'L': return 'TINYINT';
+
+      case 'I': return 'INT';
+      case 'I1': return 'TINYINT';
+      case 'I2': return 'SMALLINT';
+      case 'I4': return 'MEDIUMINT';
+      case 'I8': return 'BIGINT';
+
+      case 'F': return 'DOUBLE';
+      case 'N': return 'NUMERIC';
+      default:
+      return $meta;
+    }
+  }
+
+
+
+
+  /**************************************
+  *
+  * SQL wrapper functions (Overriding parent methods)
+  * (For use in your applications)
+  *
+  **************************************/
+
+  /**
+        * Returns the error status on the most recent sql() execution (based on $this->lastHandlerKey)
+        *
+        * @return      string          Handler error strings
+        */
+  function sql_error() {
+
+    switch($this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $output = mysql_error($this->handlerInstance[$this->lastHandlerKey]['link']);
+      break;
+      case 'adodb':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->ErrorMsg();
+      break;
+      case 'userdefined':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->sql_error();
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Returns the number of selected rows.
+        *
+        * @param       pointer         Result pointer / DBAL object
+        * @return      integer         Number of resulting rows.
+        */
+  function sql_num_rows(&$res) {
+
+    $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_num_rows($res);
+      break;
+      case 'adodb':
+                       $output = method_exists($res, 'RecordCount') ? $res->RecordCount() : 0;
+      break;
+      case 'userdefined':
+      $output = $res->sql_num_rows();
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Returns an associative array that corresponds to the fetched row, or FALSE if there are no more rows.
+        *
+        * @param       pointer         MySQL result pointer (of SELECT query) / DBAL object
+        * @return      array           Associative array of result row.
+        */
+  function sql_fetch_assoc(&$res)      {
+
+    $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_fetch_assoc($res);
+      $tableList = $this->resourceIdToTableNameMap[(string)$res];      // Reading list of tables from SELECT query:
+      break;
+      case 'adodb':
+                       // Check if method exists for the current $res object.
+                       // If a table exists in TCA but not in the db, a error
+                       // occured because $res is not a valid object.
+                       if(method_exists($res, 'FetchRow')) {
+      $output = $res->FetchRow();
+      $tableList = $res->TYPO3_DBAL_tableList; // Reading list of tables from SELECT query:
+
+      // Removing all numeric/integer keys.
+      // Just a temporary workaround till I know how to make ADOdb return this by default... Most likely this will not work with other databases than MySQL
+      if (is_array($output))   {
+        foreach($output as $key => $value)     {
+          if (is_integer($key))        unset($output[$key]);
+        }
+      }
+                       }
+      break;
+      case 'userdefined':
+      $output = $res->sql_fetch_assoc();
+      $tableList = $res->TYPO3_DBAL_tableList; // Reading list of tables from SELECT query:
+      break;
+    }
+
+    // Table/Fieldname mapping:
+    if (is_array($output))     {
+      if ($tables = $this->map_needMapping($tableList,TRUE))   {
+        $output = $this->map_assocArray($output,$tables,1);
+      }
+    }
+
+    // Return result:
+    return $output;
+  }
+
+  /**
+        * Returns an array that corresponds to the fetched row, or FALSE if there are no more rows.
+        * The array contains the values in numerical indices.
+        *
+        * @param       pointer         MySQL result pointer (of SELECT query) / DBAL object
+        * @return      array           Array with result rows.
+        */
+  function sql_fetch_row(&$res)        {
+    $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_fetch_row($res);
+      break;
+      case 'adodb':
+                       // Check if method exists for the current $res object.
+                       // If a table exists in TCA but not in the db, a error
+                       // occured because $res is not a valid object.
+                       if(method_exists($res, 'FetchRow')) {
+      $output = $res->FetchRow();
+
+      // Removing all assoc. keys.
+      // Just a temporary workaround till I know how to make ADOdb return this by default... Most likely this will not work with other databases than MySQL
+      if (is_array($output))   {
+        foreach($output as $key => $value)     {
+          if (!is_integer($key))       unset($output[$key]);
+        }
+      }
+                       }
+      break;
+      case 'userdefined':
+      $output = $res->sql_fetch_row();
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Free result memory / unset result object
+        *
+        * @param       pointer         MySQL result pointer to free / DBAL object
+        * @return      boolean         Returns TRUE on success or FALSE on failure.
+        */
+  function sql_free_result(&$res)      {
+
+    $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_free_result($res);
+      break;
+      case 'adodb':
+                       if(method_exists($res, 'Close')) {
+      $res->Close();
+      unset($res);
+      $output = true;
+                       } else {
+                               $output = false;
+                       }
+      break;
+      case 'userdefined':
+      unset($res);
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Get the ID generated from the previous INSERT operation
+        *
+        * @return      integer         The uid of the last inserted record.
+        */
+  function sql_insert_id()     {
+
+    switch($this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $output = mysql_insert_id($this->handlerInstance[$this->lastHandlerKey]['link']);
+      break;
+      case 'adodb':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->last_insert_id;
+      break;
+      case 'userdefined':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->sql_insert_id();
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Returns the number of rows affected by the last INSERT, UPDATE or DELETE query
+        *
+        * @return      integer         Number of rows affected by last query
+        */
+  function sql_affected_rows() {
+
+    switch($this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $output = mysql_affected_rows();
+      break;
+      case 'adodb':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->Affected_Rows();
+      break;
+      case 'userdefined':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->sql_affected_rows();
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Move internal result pointer
+        *
+        * @param       pointer         MySQL result pointer (of SELECT query) / DBAL object
+        * @param       integer         Seek result number.
+        * @return      boolean         Returns TRUE on success or FALSE on failure.
+        */
+  function sql_data_seek(&$res,$seek)  {
+
+    $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_data_seek($res,$seek);
+      break;
+      case 'adodb':
+      $output = $res->Move($seek);
+      break;
+      case 'userdefined':
+      $output = $res->sql_data_seek($seek);
+      break;
+    }
+    return $output;
+  }
+
+  /**
+        * Get the type of the specified field in a result
+        *
+        * If the first parameter is a string, it is used as table name for the lookup.
+        *
+        * @param       pointer         MySQL result pointer (of SELECT query) / DBAL object / table name
+        * @param       integer         Field index. In case of ADOdb a string (field name!) FIXME
+        * @return      string          Returns the type of the specified field index
+        */
+  function sql_field_metatype($table,$field)   {
+    return $this->cache_fieldType[$table][$field]['metaType'];
+  }
+
+  /**
+        * Get the type of the specified field in a result
+        *
+        * If the first parameter is a string, it is used as table name for the lookup.
+        *
+        * @param       pointer         MySQL result pointer (of SELECT query) / DBAL object / table name
+        * @param       integer         Field index. In case of ADOdb a string (field name!) FIXME
+        * @return      string          Returns the type of the specified field index
+        */
+  function sql_field_type(&$res,$pointer)      {
+    if($res === null) {
+      debug(array('no res in sql_field_type!'));
+      return 'text';
+    }
+    else if(is_string($res)){
+      if($res == 'tx_dbal_debuglog') return 'text';
+      $handlerType = 'adodb';
+    }
+    else {
+      $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+    }
+
+    switch($handlerType)       {
+      case 'native':
+      $output = mysql_field_type($res,$pointer);
+      break;
+      case 'adodb':
+                       if(is_string($pointer)){
+      $output = $this->cache_fieldType[$res][$pointer]['type'];
+                       }
+
+      break;
+      case 'userdefined':
+      $output = $res->sql_field_type($pointer);
+      break;
+    }
+
+    return $output;
+  }
+
+
+
+
+
+
+
+
+  /**********
+  *
+  * Legacy functions, bound to _DEFAULT handler. (Overriding parent methods)
+  * Depreciated.
+  *
+  **********/
+
+  /**
+        * Executes query (on DEFAULT handler!)
+        * DEPRECIATED - use exec_* functions from this class instead!
+        *
+        * @param       string          Database name
+        * @param       string          Query to execute
+        * @return      pointer         Result pointer
+        * @depreciated
+        */
+  function sql($db,$query)     {
+    return $this->sql_query($query);
+  }
+
+  /**
+        * Executes query (on DEFAULT handler!)
+        * DEPRECIATED - use exec_* functions from this class instead!
+        *
+        * @param       string          Query to execute
+        * @return      pointer         Result pointer / DBAL object
+        * @depreciated
+        */
+  function sql_query($query)   {
+
+    switch($this->handlerCfg['_DEFAULT']['type'])      {
+      case 'native':
+      $sqlResult = mysql_query($query, $this->handlerInstance['_DEFAULT']['link']);
+      break;
+      case 'adodb':
+      $sqlResult = $this->handlerInstance['_DEFAULT']->Execute($query);
+      break;
+      case 'userdefined':
+      $sqlResult = $this->handlerInstance['_DEFAULT']->sql_query($query);
+      break;
+    }
+
+    // Print errors:
+    if ($this->printErrors && $this->sql_error())      { debug(array($this->sql_error()));     }
+
+    return $sqlResult;
+  }
+
+  /**
+        * Opening the _DEFAULT connection handler to the database.
+        * This is typically done by the scripts "init.php" in the backend or "index_ts.php" in the frontend (tslib_fe->connectToMySQL())
+        * You wouldn't need to use this at any time - let TYPO3 core handle this.
+        *
+        * @param       string          Database host IP/domain
+        * @param       string          Username to connect with.
+        * @param       string          Password to connect with.
+        * @return      mixed           Returns handler connection value
+        * @depreciated
+        * @see handler_init()
+        */
+  function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)        {
+    // Overriding the _DEFAULT handler configuration of username, password, localhost and database name:
+    $this->handlerCfg['_DEFAULT']['config']['username'] = $TYPO3_db_username;
+    $this->handlerCfg['_DEFAULT']['config']['password'] = $TYPO3_db_password;
+    $this->handlerCfg['_DEFAULT']['config']['host'] = $TYPO3_db_host;
+    $this->handlerCfg['_DEFAULT']['config']['database'] = TYPO3_db;
+
+    // Initializing and output value:
+    $sqlResult = $this->handler_init('_DEFAULT');
+    return $sqlResult;
+  }
+
+  /**
+        * Select database for _DEFAULT handler.
+        *
+        * @param       string          Database to connect to.
+        * @return      boolean         Always returns true; function is obsolete, database selection is made in handler_init() function!
+        * @depreciated
+        */
+  function sql_select_db($TYPO3_db)    {
+    return TRUE;
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  /**************************************
+  *
+  * SQL admin functions
+  * (For use in the Install Tool and Extension Manager)
+  *
+  **************************************/
+
+  /**
+        * Listing databases from current MySQL connection. NOTICE: It WILL try to select those databases and thus break selection of current database.
+        * Use in Install Tool only!
+        * Usage count/core: 1
+        *
+        * @return      array           Each entry represents a database name
+        */
+  function admin_get_dbs()     {
+    $dbArr = array();
+    switch($this->handlerCfg['_DEFAULT']['type'])      {
+      case 'native':
+      $db_list = mysql_list_dbs($this->link);
+      while ($row = mysql_fetch_object($db_list)) {
+        if ($this->sql_select_db($row->Database))      {
+          $dbArr[] = $row->Database;
+        }
+      }
+      break;
+      case 'adodb':
+       // check needed for install tool - otherwise it will just die because the call to
+       // MetaDatabases is done on a stdClass instance
+      if(method_exists($this->handlerInstance['_DEFAULT'],'MetaDatabases')) {
+             $sqlDBs = $this->handlerInstance['_DEFAULT']->MetaDatabases();
+           foreach( $sqlDBs as $k => $theDB) {
+           $dbArr[] = $theDB;
+       }
+      }
+      break;
+      case 'userdefined':
+      $dbArr = $this->handlerInstance['_DEFAULT']->admin_get_tables();
+      break;
+    }
+
+    return $dbArr;
+  }
+
+  /**
+        * Returns the list of tables from the system (quering the DBMSs)
+        * It looks up all tables from the DBMS of the _DEFAULT handler and then add all tables *configured* to be managed by other handlers
+        *
+        * @return      array           Tables in an array (tablename is in both key and value)
+        */
+  function admin_get_tables()  {
+    $whichTables = array();
+
+    // Getting real list of tables:
+    switch($this->handlerCfg['_DEFAULT']['type'])      {
+      case 'native':
+      $tables_result = mysql_list_tables(TYPO3_db, $this->handlerInstance['_DEFAULT']['link']);
+      if (!$this->sql_error()) {
+        while ($theTable = $this->sql_fetch_assoc($tables_result)) {
+          $whichTables[current($theTable)] = current($theTable);
+        }
+      }
+      break;
+      case 'adodb':
+      $sqlTables = $this->handlerInstance['_DEFAULT']->MetaTables('TABLES');
+      while (list($k, $theTable) = each($sqlTables)) {
+        $whichTables[$theTable] = $theTable;
+      }
+      break;
+      case 'userdefined':
+      $whichTables = $this->handlerInstance['_DEFAULT']->admin_get_tables();
+      break;
+    }
+
+    // Check mapping:
+    if (is_array($this->mapping))      {
+
+      // Mapping table names in reverse, first getting list of real table names:
+      $tMap = array();
+      foreach($this->mapping as $tN => $tMapInfo)      {
+        if (isset($tMapInfo['mapTableName']))  $tMap[$tMapInfo['mapTableName']]=$tN;
+      }
+
+      // Do mapping:
+      $newList=array();
+      foreach($whichTables as $tN)     {
+        if (isset($tMap[$tN])) $tN = $tMap[$tN];
+        $newList[$tN] = $tN;
+      }
+
+      $whichTables = $newList;
+    }
+
+    // Adding tables configured to reside in other DBMS (handler by other handlers than the default):
+    if (is_array($this->table2handlerKeys))    {
+      foreach($this->table2handlerKeys as $key => $handlerKey) {
+        $whichTables[$key] = $key;
+      }
+    }
+
+    return $whichTables;
+  }
+
+  /**
+        * Returns information about each field in the $table (quering the DBMS)
+        * In a DBAL this should look up the right handler for the table and return compatible information
+        * This function is important not only for the Install Tool but probably for DBALs as well since they might need to look up table specific information in order to construct correct queries. In such cases this information should probably be cached for quick delivery
+        *
+        * @param       string          Table name
+        * @return      array           Field information in an associative array with fieldname => field row
+        */
+  function admin_get_fields($tableName)        {
+    $output = array();
+
+    // Do field mapping if needed:
+    $ORIG_tableName = $tableName;
+    if ($tableArray = $this->map_needMapping($tableName))      {
+
+      // Table name:
+      if ($this->mapping[$tableName]['mapTableName'])  {
+        $tableName = $this->mapping[$tableName]['mapTableName'];
+      }
+    }
+
+    // Find columns
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $columns_res = mysql_query('SHOW columns FROM '.$tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      while($fieldRow = mysql_fetch_assoc($columns_res))       {
+        $output[$fieldRow['Field']] = $fieldRow;
+      }
+      break;
+      case 'adodb':
+      $fieldRows = $this->handlerInstance[$this->lastHandlerKey]->MetaColumns($tableName, false);
+      foreach($fieldRows as $k => $fieldRow) {
+        settype($fieldRow, 'array');
+        $fieldRow['Field'] = $fieldRow['name'];
+        $ntype = $this->MySQLActualType($this->MetaType($fieldRow['type'],$tableName));
+        $ntype .= (($fieldRow['max_length'] != -1) ? (($ntype == 'INT') ? '(11)' :'('.$fieldRow['max_length'].')') : '');
+        $fieldRow['Type'] = strtolower($ntype);
+        $fieldRow['Null'] = '';
+        $fieldRow['Key'] = '';
+        $fieldRow['Default'] = $fieldRow['default_value'];
+        $fieldRow['Extra'] = '';
+        $output[$fieldRow['name']] = $fieldRow;
+      }
+      break;
+      case 'userdefined':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->admin_get_fields($tableName);
+      break;
+    }
+
+    // mapping should be done:
+    if (is_array($tableArray) && is_array($this->mapping[$ORIG_tableName]['mapFieldNames']))   {
+      $revFields = array_flip($this->mapping[$ORIG_tableName]['mapFieldNames']);
+
+      $newOutput = array();
+      foreach($output as $fN => $fInfo)        {
+        if (isset($revFields[$fN]))    {
+          $fN = $revFields[$fN];
+          $fInfo['Field'] = $fN;
+        }
+        $newOutput[$fN] = $fInfo;
+      }
+      $output = $newOutput;
+    }
+
+    return $output;
+  }
+
+  /**
+        * Returns information about each index key in the $table (quering the DBMS)
+        * In a DBAL this should look up the right handler for the table and return compatible information
+        *
+        * @param       string          Table name
+        * @return      array           Key information in a numeric array
+        */
+  function admin_get_keys($tableName)  {
+    $output = array();
+
+    // Do field mapping if needed:
+    $ORIG_tableName = $tableName;
+    if ($tableArray = $this->map_needMapping($tableName))      {
+
+      // Table name:
+      if ($this->mapping[$tableName]['mapTableName'])  {
+        $tableName = $this->mapping[$tableName]['mapTableName'];
+      }
+    }
+
+    // Find columns
+    $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+    switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])   {
+      case 'native':
+      $keyRes = mysql_query('SHOW keys FROM '.$tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);
+      while($keyRow = mysql_fetch_assoc($keyRes))      {
+        $output[] = $keyRow;
+      }
+      break;
+      case 'adodb':
+      $keyRows = $this->handlerInstance[$this->lastHandlerKey]->MetaIndexes($tableName);
+      if($keyRows !== false) {
+        while (list($k, $theKey) = each($keyRows)) {
+          $theKey['Table'] = $tableName;
+          $theKey['Non_unique'] = (int) !$theKey['unique'];
+          $theKey['Key_name'] = str_replace($tableName.'_','',$k);
+
+          // the following are probably not needed anyway...
+          $theKey['Collation'] = '';
+          $theKey['Cardinality'] = '';
+          $theKey['Sub_part'] = '';
+          $theKey['Packed'] = '';
+          $theKey['Null'] = '';
+          $theKey['Index_type'] = '';
+          $theKey['Comment'] = '';
+
+          // now map multiple fields into multiple rows (we mimic MySQL, remember...)
+          $keycols = $theKey['columns'];
+          while (list($c, $theCol) = each($keycols)) {
+            $theKey['Seq_in_index'] = $c+1;
+            $theKey['Column_name'] = $theCol;
+            $output[] = $theKey;
+          }
+        }
+      }
+      $priKeyRow = $this->handlerInstance[$this->lastHandlerKey]->MetaPrimaryKeys($tableName);
+      $theKey = array();
+      $theKey['Table'] = $tableName;
+      $theKey['Non_unique'] = 0;
+      $theKey['Key_name'] = 'PRIMARY';
+
+      // the following are probably not needed anyway...
+      $theKey['Collation'] = '';
+      $theKey['Cardinality'] = '';
+      $theKey['Sub_part'] = '';
+      $theKey['Packed'] = '';
+      $theKey['Null'] = '';
+      $theKey['Index_type'] = '';
+      $theKey['Comment'] = '';
+
+      // now map multiple fields into multiple rows (we mimic MySQL, remember...)
+      if($priKeyRow !== false) {
+        while (list($c, $theCol) = each($priKeyRow)) {
+          $theKey['Seq_in_index'] = $c+1;
+          $theKey['Column_name'] = $theCol;
+          $output[] = $theKey;
+        }
+      }
+      break;
+      case 'userdefined':
+      $output = $this->handlerInstance[$this->lastHandlerKey]->admin_get_keys($tableName);
+      break;
+    }
+
+    // mapping should be done:
+    if (is_array($tableArray) && is_array($this->mapping[$ORIG_tableName]['mapFieldNames']))   {
+      $revFields = array_flip($this->mapping[$ORIG_tableName]['mapFieldNames']);
+
+      $newOutput = array();
+      foreach($output as $kN => $kInfo)        {
+        // Table:
+        $kInfo['Table'] = $ORIG_tableName;
+
+        // Column
+        if (isset($revFields[$kInfo['Column_name']]))  {
+          $kInfo['Column_name'] = $revFields[$kInfo['Column_name']];
+        }
+
+        // Write it back:
+        $newOutput[$kN] = $kInfo;
+      }
+      $output = $newOutput;
+    }
+
+    return $output;
+  }
+
+  /**
+        * 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
+        */
+  function admin_query($query) {
+    $parsedQuery = $this->SQLparser->parseSQL($query);
+    $ORIG_table = $parsedQuery['TABLE'];
+
+    if (is_array($parsedQuery))        {
+
+      // Process query based on type:
+      switch($parsedQuery['type'])     {
+        case 'CREATETABLE':
+        case 'ALTERTABLE':
+        case 'DROPTABLE':
+        if(file_exists(PATH_typo3conf.'temp_fieldInfo.php'))
+        unlink(PATH_typo3conf.'temp_fieldInfo.php');
+        $this->map_genericQueryParsed($parsedQuery);
+        break;
+        case 'INSERT':
+        $this->map_genericQueryParsed($parsedQuery);
+        break;
+        default:
+        die('ERROR: Invalid Query type ('.$parsedQuery['type'].') for ->admin_query() function!: "'.htmlspecialchars($query).'"');
+        break;
+      }
+
+      // Setting query array (for other applications to access if needed)
+      $this->lastParsedAndMappedQueryArray = $parsedQuery;
+
+      // Execute query (based on handler derived from the TABLE name which we actually know for once!)
+      $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_table);
+      switch((string)$this->handlerCfg[$this->lastHandlerKey]['type']) {
+        case 'native':
+        // Compiling query:
+        $compiledQuery =  $this->SQLparser->compileSQL($this->lastParsedAndMappedQueryArray);
+
+        return mysql_query($compiledQuery[0], $this->link);
+        break;
+        case 'adodb':
+        // Compiling query:
+        $compiledQuery =  $this->SQLparser->compileSQL($this->lastParsedAndMappedQueryArray);
+        if($this->lastParsedAndMappedQueryArray['type']=='INSERT') {
+          return $this->exec_INSERTquery($this->lastParsedAndMappedQueryArray['TABLE'],$compiledQuery);
+        }
+        return $this->handlerInstance[$this->lastHandlerKey]->DataDictionary->ExecuteSQLArray($compiledQuery);
+        break;
+        case 'userdefined':
+        // Compiling query:
+        $compiledQuery =  $this->SQLparser->compileSQL($this->lastParsedAndMappedQueryArray);
+
+        return $this->handlerInstance[$this->lastHandlerKey]->admin_query($compiledQuery);
+        break;
+      }
+    } else die('ERROR: Query could not be parsed: "'.htmlspecialchars($parsedQuery).'". Query: "'.htmlspecialchars($query).'"');
+  }
+
+
+
+
+
+
+
+
+
+
+  /************************************
+  *
+  * Handler management
+  *
+  **************************************/
+
+  /**
+        * Return the handler key pointing to an appropriate database handler as found in $this->handlerCfg array
+        * Notice: TWO or more tables in the table list MUST use the SAME handler key - otherwise a fatal error is thrown! (Logically, no database can possibly join two tables from separate sources!)
+        *
+        * @param       string          Table list, eg. "pages" or "pages, tt_content" or "pages AS A, tt_content AS B"
+        * @return      string          Handler key (see $this->handlerCfg array) for table
+        */
+  function handler_getFromTableList($tableList)        {
+
+    $key = $tableList;
+
+    if (!isset($this->cache_handlerKeyFromTableList[$key]))    {
+
+      // Get tables separated:
+      $_tableList = $tableList;
+      $tableArray = $this->SQLparser->parseFromTables($_tableList);
+
+      // If success, traverse the tables:
+      if (is_array($tableArray) && count($tableArray)) {
+        foreach($tableArray as $vArray)        {
+
+          // Find handler key, select "_DEFAULT" if none is specifically configured:
+          $handlerKey = $this->table2handlerKeys[$vArray['table']] ? $this->table2handlerKeys[$vArray['table']] : '_DEFAULT';
+
+          // In case of separate handler keys for joined tables:
+          if ($outputHandlerKey && $handlerKey != $outputHandlerKey)   {
+            die('DBAL fatal error: Tables in this list "'.$tableList.'" didn\'t use the same DB handler!');
+          }
+
+          $outputHandlerKey = $handlerKey;
+        }
+
+        // Check initialized state; if handler is NOT initialized (connected) then we will connect it!
+        if (!isset($this->handlerInstance[$outputHandlerKey])) {
+          $this->handler_init($outputHandlerKey);
+        }
+
+        // Return handler key:
+        $this->cache_handlerKeyFromTableList[$key] = $outputHandlerKey;
+      } else {
+        die('DBAL fatal error: No tables found: "'.$tableList.'"');
+      }
+    }
+
+    return $this->cache_handlerKeyFromTableList[$key];
+  }
+
+  /**
+        * Initialize handler (connecting to database)
+        *
+        * @param       string          Handler key
+        * @return      boolean         If connection went well, return true
+        * @see handler_getFromTableList()
+        */
+  function handler_init($handlerKey)   {
+
+    // Find handler configuration:
+    $cfgArray = $this->handlerCfg[$handlerKey];
+    $handlerType = (string)$cfgArray['type'];
+    $output = FALSE;
+
+    if (is_array($cfgArray))   {
+      switch($handlerType)     {
+        case 'native':
+        $link = mysql_pconnect(
+        $cfgArray['config']['host'],
+        $cfgArray['config']['username'],
+        $cfgArray['config']['password']
+        );
+
+        // Set handler instance:
+        $this->handlerInstance[$handlerKey] = array(
+        'handlerType' => 'native',
+        'link' => $link
+        );
+
+        // If link succeeded:
+        if ($link)     {
+
+          // For default, set ->link (see t3lib_DB)
+          if ($handlerKey == '_DEFAULT') {
+            $this->link = $link;
+          }
+
+          // Select database as well:
+          if (mysql_select_db($cfgArray['config']['database'], $link)) {
+            $output = TRUE;
+          }
+        }
+        break;
+        case 'adodb':
+        $output = true;
+        require_once (t3lib_extMgm::extPath('adodb').'adodb/adodb.inc.php');
+        if(!defined('ADODB_FORCE_NULLS')) define('ADODB_FORCE_NULLS',1);
+        $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
+
+        $dsn = $cfgArray['config']['driver'].'://'.
+        rawurlencode($cfgArray['config']['username']).':'.
+        rawurlencode($cfgArray['config']['password']).'@'.
+        rawurlencode($cfgArray['config']['host']).'/'.
+        rawurlencode($cfgArray['config']['database']).
+        '?persistent=1&fetchmode='.ADODB_FETCH_BOTH;
+        $this->handlerInstance[$handlerKey] = &ADONewConnection($dsn);
+        if($this->handlerInstance[$handlerKey] === false) {
+          error_log('DBAL error: Connection to '.$dsn.' failed. Maybe PHP doesn\'t support the database?');
+               $output = false;
+        }
+
+        $this->handlerInstance[$handlerKey]->DataDictionary  = NewDataDictionary($this->handlerInstance[$handlerKey]);
+        $this->handlerInstance[$handlerKey]->last_insert_id = 0;
+        break;
+        case 'userdefined':
+        // Find class file:
+        $fileName = t3lib_div::getFileAbsFileName($cfgArray['config']['classFile']);
+        if (@is_file($fileName))       {
+          require_once($fileName);
+        } else die('DBAL error: "'.$fileName.'" was not a file to include.');
+
+        // Initialize:
+        $this->handlerInstance[$handlerKey] = t3lib_div::makeInstance($cfgArray['config']['class']);
+        $this->handlerInstance[$handlerKey]->init($cfgArray,$this);
+
+        if (is_object($this->handlerInstance[$handlerKey]))            {
+          $output = TRUE;
+        }
+        break;
+        default:
+        die('ERROR: Invalid handler type: "'.$cfgArray['type'].'"');
+        break;
+      }
+
+      return $output;
+    } else die('ERROR: No handler for key "'.$handlerKey.'"');
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  /************************************
+  *
+  * Table/Field mapping
+  *
+  **************************************/
+
+  /**
+        * Checks if mapping is needed for a table(list)
+        *
+        * @param       string          List of tables in query
+        * @param       boolean         If true, it will check only if FIELDs are configured and ignore the mapped table name if any.
+        * @return      mixed           Returns an array of table names (parsed version of input table) if mapping is needed, otherwise just false.
+        */
+  function map_needMapping($tableList,$fieldMappingOnly=FALSE) {
+
+    $key = $tableList.'|'.$fieldMappingOnly;
+    if (!isset($this->cache_mappingFromTableList[$key]))       {
+      $this->cache_mappingFromTableList[$key] = FALSE; // Default:
+
+      $tables = $this->SQLparser->parseFromTables($tableList);
+      if (is_array($tables))   {
+        foreach($tables as $tableCfg)  {
+          if ($fieldMappingOnly)       {
+            if (is_array($this->mapping[$tableCfg['table']]['mapFieldNames'])) {
+              $this->cache_mappingFromTableList[$key] = $tables;
+            }
+          } else {
+            if (is_array($this->mapping[$tableCfg['table']]))  {
+              $this->cache_mappingFromTableList[$key] = $tables;
+            }
+          }
+        }
+      }
+    }
+
+    return $this->cache_mappingFromTableList[$key];
+  }
+
+  /**
+        * Takes an associated array with field => value pairs and remaps the field names if configured for this table in $this->mapping array.
+        * Be careful not to map a field name to another existing fields name (although you can use this to swap fieldnames of course...:-)
+        * Observe mapping problems with join-results (more than one table): Joined queries should always prefix the table name to avoid problems with this.
+        * Observe that alias fields are not mapped of course (should not be a problem though)
+        *
+        * @param       array           Input array, associative keys
+        * @param       array           Array of tables from the query. Normally just one table; many tables in case of a join. NOTICE: for multiple tables (with joins) there MIGHT occur trouble with fields of the same name in the two tables: This function traverses the mapping information for BOTH tables and applies mapping without checking from which table the field really came!
+        * @param       boolean         If true, reverse direction. Default direction is to map an array going INTO the database (thus mapping TYPO3 fieldnames to PHYSICAL field names!)
+        * @return      array           Output array, with mapped associative keys.
+        */
+  function map_assocArray($input,$tables,$rev=FALSE)   {
+
+    // Traverse tables from query (hopefully only one table):
+    foreach($tables as $tableCfg)      {
+      if (is_array($this->mapping[$tableCfg['table']]['mapFieldNames']))       {
+
+        // Get the map (reversed if needed):
+        if ($rev)      {
+          $theMap = array_flip($this->mapping[$tableCfg['table']]['mapFieldNames']);
+        } else {
+          $theMap = $this->mapping[$tableCfg['table']]['mapFieldNames'];
+        }
+
+        // Traverse selected record, map fieldnames:
+        $output = array();
+        foreach($input as $fN => $value)       {
+
+          // Set the field name, change it if found in mapping array:
+          if ($theMap[$fN])    {
+            $newKey = $theMap[$fN];
+          } else {
+            $newKey = $fN;
+          }
+
+          // Set value to fieldname:
+          $output[$newKey] = $value;
+        }
+
+        // When done, override the $input array with the result:
+        $input = $output;
+      }
+    }
+
+    // Return input array (which might have been altered in the mean time)
+    return $input;
+  }
+
+  /**
+        * Remaps table/field names in a SELECT query's parts
+        * Notice: All arguments are passed by reference!
+        *
+        * @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 ...". Require value.
+        * @param       string          Where clause. This is what comes right after "WHERE ...". Can be blank.
+        * @param       string          Group by field(s)
+        * @param       string          Order by field(s)
+        * @return      void
+        * @see exec_SELECTquery()
+        */
+  function map_remapSELECTQueryParts(&$select_fields,&$from_table,&$where_clause,&$groupBy,&$orderBy)  {
+
+    // Tables:
+    $tables = $this->SQLparser->parseFromTables($from_table);
+    $defaultTable = $tables[0]['table'];
+    foreach($tables as $k => $v)       {
+      if ($this->mapping[$v['table']]['mapTableName']) {
+        $tables[$k]['table'] = $this->mapping[$v['table']]['mapTableName'];
+      }
+    }
+    $from_table = $this->SQLparser->compileFromTables($tables);
+
+    // Where clause:
+    $whereParts = $this->SQLparser->parseWhereClause($where_clause);
+    $this->map_sqlParts($whereParts,$defaultTable);
+    $where_clause = $this->SQLparser->compileWhereClause($whereParts);
+
+    // Select fields:
+    $expFields = $this->SQLparser->parseFieldList($select_fields);
+    $this->map_sqlParts($expFields,$defaultTable);
+    $select_fields = $this->SQLparser->compileFieldList($expFields);
+
+    // Group By fields
+    $expFields = $this->SQLparser->parseFieldList($groupBy);
+    $this->map_sqlParts($expFields,$defaultTable);
+    $groupBy = $this->SQLparser->compileFieldList($expFields);
+
+    // Order By fields
+    $expFields = $this->SQLparser->parseFieldList($orderBy);
+    $this->map_sqlParts($expFields,$defaultTable);
+    $orderBy = $this->SQLparser->compileFieldList($expFields);
+  }
+
+  /**
+        * Generic mapping of table/field names arrays (as parsed by t3lib_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
+        * @return      void
+        * @access private
+        * @see map_remapSELECTQueryParts()
+        */
+  function map_sqlParts(&$sqlPartArray, $defaultTable) {
+
+    // Traverse sql Part array:
+    if (is_array($sqlPartArray))       {
+      foreach($sqlPartArray as $k => $v)       {
+
+        // Look for sublevel (WHERE parts only)
+        if (is_array($sqlPartArray[$k]['sub']))        {
+          $this->map_sqlParts($sqlPartArray[$k]['sub'], $defaultTable);        // Call recursively!
+        } else {
+          // For the field, look for table mapping (generic):
+          $t = $sqlPartArray[$k]['table'] ? $sqlPartArray[$k]['table'] : $defaultTable;
+
+          // Mapping field name, if set:
+          if (is_array($this->mapping[$t]['mapFieldNames']) && $this->mapping[$t]['mapFieldNames'][$sqlPartArray[$k]['field']])        {
+            $sqlPartArray[$k]['field'] = $this->mapping[$t]['mapFieldNames'][$sqlPartArray[$k]['field']];
+          }
+
+          // Map table?
+          if ($sqlPartArray[$k]['table'] && $this->mapping[$sqlPartArray[$k]['table']]['mapTableName'])        {
+            $sqlPartArray[$k]['table'] = $this->mapping[$sqlPartArray[$k]['table']]['mapTableName'];
+          }
+        }
+      }
+    }
+  }
+
+  /**
+        * Will do table/field mapping on a general t3lib_sqlengine-compliant SQL query
+        * (May still not support all query types...)
+        *
+        * @param       array           Parsed QUERY as from t3lib_sqlengine::parseSQL(). NOTICE: Passed by reference!
+        * @return      void
+        * @see t3lib_sqlengine::parseSQL()
+        */
+  function map_genericQueryParsed(&$parsedQuery)       {
+
+    // Getting table - same for all:
+    $table = $parsedQuery['TABLE'];
+    if ($table)        {
+      // Do field mapping if needed:
+      if ($tableArray = $this->map_needMapping($table))        {
+
+        // Table name:
+        if ($this->mapping[$table]['mapTableName'])    {
+          $parsedQuery['TABLE'] = $this->mapping[$table]['mapTableName'];
+        }
+
+        // Based on type, do additional changes:
+        switch($parsedQuery['type'])   {
+          case 'ALTERTABLE':
+
+          // Changing field name:
+          $newFieldName = $this->mapping[$table]['mapFieldNames'][$parsedQuery['FIELD']];
+          if ($newFieldName)   {
+            if ($parsedQuery['FIELD'] == $parsedQuery['newField'])     {
+              $parsedQuery['FIELD'] = $parsedQuery['newField'] = $newFieldName;
+            } else $parsedQuery['FIELD'] = $newFieldName;
+          }
+
+          // Changing key field names:
+          if (is_array($parsedQuery['fields']))        {
+            $this->map_fieldNamesInArray($table,$parsedQuery['fields']);
+          }
+          break;
+          case 'CREATETABLE':
+          // Remapping fields:
+          if (is_array($parsedQuery['FIELDS']))        {
+            $newFieldsArray = array();
+            foreach($parsedQuery['FIELDS'] as $fN => $fInfo)   {
+              if ($this->mapping[$table]['mapFieldNames'][$fN])        {
+                $fN = $this->mapping[$table]['mapFieldNames'][$fN];
+              }
+              $newFieldsArray[$fN] = $fInfo;
+            }
+            $parsedQuery['FIELDS'] = $newFieldsArray;
+          }
+
+          // Remapping keys:
+          if (is_array($parsedQuery['KEYS']))  {
+            foreach($parsedQuery['KEYS'] as $kN => $kInfo)     {
+              $this->map_fieldNamesInArray($table,$parsedQuery['KEYS'][$kN]);
+            }
+          }
+          break;
+
+
+          /// ... and here support for all other query types should be!
+
+
+        }
+      }
+    } else die('ERROR, mapping: No table found in parsed Query array...');
+  }
+
+  /**
+        * Re-mapping field names in array
+        *
+        * @param       string          (TYPO3) Table name for fields.
+        * @param       array           Array of fieldnames to remap. Notice: Passed by reference!
+        * @return      void
+        */
+  function map_fieldNamesInArray($table,&$fieldArray)  {
+    if (is_array($this->mapping[$table]['mapFieldNames']))     {
+      foreach($fieldArray as $k => $v) {
+        if ($this->mapping[$table]['mapFieldNames'][$v])       {
+          $fieldArray[$k] = $this->mapping[$table]['mapFieldNames'][$v];
+        }
+      }
+    }
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  /**************************************
+  *
+  * Debugging
+  *
+  **************************************/
+
+  /**
+        * Debug handler for query execution
+        *
+        * @param       string          Function name from which this function is called.
+        * @param       string          Execution time in ms of the query
+        * @param       array           In-data of various kinds.
+        * @return      void
+        * @access private
+        */
+  function debugHandler($function,$execTime,$inData)   {
+    // we don't want to log our own log/debug SQL
+    $script = substr(PATH_thisScript,strlen(PATH_site));
+    if (substr($script,-strlen('dbal/mod1/index.php'))!='dbal/mod1/index.php' &&
+    !strstr($inData['args'][0], 'tx_dbal_debuglog'))   {
+      $data = array();
+      $errorFlag = 0;
+      $joinTable = '';
+
+      if ($this->sql_error())  {
+        $data['sqlError'] = $this->sql_error();
+        $errorFlag|=1;
+      }
+
+      // if lastQuery is empty (for whatever reason) at least log inData.args
+      if(empty($this->lastQuery))
+      $query = implode(' ',$inData['args']);
+      else
+      $query = $this->lastQuery;
+
+      switch($function)        {
+        case 'exec_INSERTquery':
+        case 'exec_UPDATEquery':
+        case 'exec_DELETEquery':
+        $this->debug_log($query,$execTime,$data,$joinTable,$errorFlag, $script);
+        break;
+
+        case 'exec_SELECTquery':
+        // Get explain data:
+        if ($this->conf['debugOptions']['EXPLAIN'] && t3lib_div::inList('adodb,native',$inData['handlerType']))        {
+          $data['EXPLAIN'] = $this->debug_explain($this->lastQuery);
+        }
+
+        // Check parsing of Query:
+        if ($this->conf['debugOptions']['parseQuery']) {
+          $parseResults = array();
+          $parseResults['SELECT'] = $this->SQLparser->debug_parseSQLpart('SELECT',$inData['args'][1]);
+          $parseResults['FROM'] = $this->SQLparser->debug_parseSQLpart('FROM',$inData['args'][0]);
+          $parseResults['WHERE'] = $this->SQLparser->debug_parseSQLpart('WHERE',$inData['args'][2]);
+          $parseResults['GROUPBY'] = $this->SQLparser->debug_parseSQLpart('SELECT',$inData['args'][3]);        // Using select field list syntax
+          $parseResults['ORDERBY'] = $this->SQLparser->debug_parseSQLpart('SELECT',$inData['args'][4]);        // Using select field list syntax
+
+          foreach($parseResults as $k => $v)   {
+            if (!strlen($parseResults[$k]))    unset($parseResults[$k]);
+          }
+          if (count($parseResults))    {
+            $data['parseError'] = $parseResults;
+            $errorFlag|=2;
+          }
+        }
+
+        // Checking joinTables:
+        if ($this->conf['debugOptions']['joinTables']) {
+          if (count(explode(',', $inData['ORIG_from_table']))>1)               {
+            $joinTable = $inData['args'][0];
+          }
+        }
+
+        // Logging it:
+        $this->debug_log($query,$execTime,$data,$joinTable,$errorFlag, $script);
+        if(!empty($inData['args'][2]))
+        $this->debug_WHERE($inData['args'][0], $inData['args'][2], $script);
+        break;
+      }
+    }
+  }
+
+  /**
+   * Log the where clause for debugging purposes.
+   *
+   * @param string $table
+   * @param string $where
+   */
+  function debug_WHERE($table,$where, $script='')      {
+    $insertArray = array (
+    'tstamp' => $GLOBALS['EXEC_TIME'],
+    'beuser_id' => intval($GLOBALS['BE_USER']->user['uid']),
+    'script' => $script,
+    'tablename' => $table,
+    'whereclause' => $where
+    );
+
+    $this->exec_INSERTquery('tx_dbal_debuglog_where', $insertArray);
+  }
+
+  /**
+        * Insert row in the log table
+        *
+        * @param       string          The current query
+        * @param       integer         Execution time of query in milliseconds
+        * @param       array           Data to be stored serialized.
+        * @param       string          Join string if there IS a join.
+        * @param       integer         Error status.
+        * @return      void
+        */
+  function debug_log($query,$ms,$data,$join,$errorFlag, $script='')    {
+    $insertArray = array (
+    'tstamp' => $GLOBALS['EXEC_TIME'],
+    'beuser_id' => intval($GLOBALS['BE_USER']->user['uid']),
+    'script' => $script,
+    'exec_time' => $ms,
+    'table_join' => $join,
+    'serdata' => serialize($data),
+    'query' => (is_array($query) ? $query[0].' WITH '.count($query[1]).' BLOB FIELDS: '.implode(', ',array_keys($query[1])) : $query),
+    'errorFlag' => $errorFlag
+    );
+
+    $this->exec_INSERTquery('tx_dbal_debuglog', $insertArray);
+  }
+
+  /**
+        * Perform EXPLAIN query on DEFAULT handler!
+        *
+        * @param       string          SELECT Query
+        * @return      array           The Explain result rows in an array
+        * @todo        Not supporting other than the default handler? And what about DBMS of other kinds than MySQL - support for EXPLAIN?
+        */
+  function debug_explain($query)       {
+    $res = $this->sql_query('EXPLAIN '.$query);
+
+    $output = array();
+    while($row = $this->sql_fetch_assoc($res)) {
+      $output[] = $row;
+    }
+    return $output;
+  }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_db.php']) {
+  include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_db.php']);
+}
+?>
diff --git a/typo3/sysext/dbal/class.ux_t3lib_sqlengine.php b/typo3/sysext/dbal/class.ux_t3lib_sqlengine.php
new file mode 100644 (file)
index 0000000..0da3035
--- /dev/null
@@ -0,0 +1,280 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2004 Kasper Skaarhoj (kasper@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     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':
+                           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];
+                               }
+                           }
+                       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':
+                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->DropTableSQL('`'.$components['TABLE'].'`');
+                       break;
+               }
+               echo '<!-- ';var_dump($query);echo ' -->'.chr(10);
+
+               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!)
+               //$this->lastHandlerKey = $this->handler_getFromTableList($ORIG_table);
+               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)  {
+                                       // the backticks get converted to the correct quote char automatically
+                                       $fieldsKeys[$fN] = '`'.$fN.'` '.$this->compileFieldCfg($fCfg['definition'],$fN);
+                               }
+
+                               foreach($components['KEYS'] as $kN => $kCfg)    {
+                                       if ($kN == 'PRIMARYKEY')        {
+                                               foreach($kCfg as $n => $field)  {
+                                                       $fieldsKeys[$field] .= ' PRIMARY';
+                                               }
+                                               } else {
+                                               $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($components['TABLE'].'_'.$kN, $components['TABLE'], $kCfg));
+                                       }
+                               }
+
+                               // Fetch table/index generation query:
+                               $query = array_merge($GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->CreateTableSQL('`'.$components['TABLE'].'`',implode(','.chr(10), $fieldsKeys)), $indexKeys);
+                       break;
+               }
+
+               return $query;
+       }
+
+       function compileALTERTABLE($components) {
+
+               // Execute query (based on handler derived from the TABLE name which we actually know for once!)
+               //$this->lastHandlerKey = $this->handler_getFromTableList($ORIG_table);
+               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
+                       case 'native':
+                               $query[] = parent::compileALTERTABLE($components);
+                       break;
+                       case 'adodb':
+                               switch(strtoupper(str_replace(array(" ","\n","\r","\t"),'',$components['action'])))     {
+                                       case 'ADD':
+                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AddColumnSQL('`'.$components['TABLE'].'`','`'.$components['FIELD'].'` '.$this->compileFieldCfg($components['definition']));
+                                       break;
+                                       case 'CHANGE':
+                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AlterColumnSQL('`'.$components['TABLE'].'`','`'.$components['FIELD'].'` '.$this->compileFieldCfg($components['definition']));
+                                       break;
+                                       case 'DROP':
+                                       case 'DROPKEY':
+                                       break;
+                                       case 'ADDKEY':
+                                       case 'ADDPRIMARYKEY':
+                                               $query.=' ('.implode(',',$components['fields']).')';
+                                       break;
+                               }
+                       break;
+               }
+               echo '<!-- ';var_dump($query);echo ' -->'.chr(10);
+
+               return $query;
+       }
+
+       /**
+        * Compile field definition
+        *
+        * @param       array           Field definition parts
+        * @return      string          Field definition string
+        */
+       function compileFieldCfg($fieldCfg,$fN='')      {
+               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
+                       case 'native':
+                               $cfg = parent::compileFieldCfg($fieldCfg,$fN);
+                       break;
+                       case 'adodb':
+                       // Set type:
+                       $cfg = $GLOBALS['TYPO3_DB']->MySQLMetaType($fieldCfg['fieldType']);
+
+                       // Add value, if any:
+                       if (strlen($fieldCfg['value']) && (in_array($cfg, array('C','C2'))))    {
+                               $cfg.=' '.$fieldCfg['value'];
+                       }
+
+                       // Add additional features:
+                       if (is_array($fieldCfg['featureIndex']))        {
+
+                               // MySQL assigns DEFAULT value automatically if NOT NULL, fake this here
+                               //if(array_key_exists('NOTNULL',$fieldCfg['featureIndex']) && !array_key_exists('DEFAULT',$fieldCfg['featureIndex']) && !array_key_exists('AUTO_INCREMENT',$fieldCfg['featureIndex'])) {
+                               if(isset($fieldCfg['featureIndex']['NOTNULL']) && !isset($fieldCfg['featureIndex']['DEFAULT']) && !isset($fieldCfg['featureIndex']['AUTO_INCREMENT'])) {
+                                       $fieldCfg['featureIndex']['DEFAULT'] = array('keyword' => 'DEFAULT', 'value' => array('','\''));
+                               }
+
+                               foreach($fieldCfg['featureIndex'] as $featureDef)       {
+                                               // unsigned only for mysql, as it is mysql specific
+                                       if($featureDef['keyword'] == 'unsigned' && !strstr($GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['config']['driver'],'mysql')) {
+                                               continue;
+                                       }
+                                               // auto_increment is removed, it is handled by (emulated) sequences
+                                       if($featureDef['keyword'] == 'auto_increment') {
+                                               continue;
+                                       }
+                                               // NOT NULL only if there is no default value, as this conflicts
+                                       if($featureDef['keyword'] == 'NOT NULL') {
+                                               if($this->checkEmptyDefaultValue($fieldCfg['featureIndex'])) // we do not have a default value or it is an empty string
+                                                       continue;
+                                               else
+                                                       $cfg.=' NOTNULL';
+                                       }
+
+                                       $cfg.=' '.$featureDef['keyword'];
+
+                                       // Add value if found:
+                                       if (is_array($featureDef['value']))     {
+                                               if(!is_numeric($featureDef['value'][0]) && empty($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;
+       }
+}
+
+
+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']);
+}
+?>
diff --git a/typo3/sysext/dbal/class.ux_t3lib_sqlparser.php b/typo3/sysext/dbal/class.ux_t3lib_sqlparser.php
new file mode 100644 (file)
index 0000000..453010c
--- /dev/null
@@ -0,0 +1,279 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2004 Kasper Skaarhoj (kasper@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     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_sqlparser extends t3lib_sqlparser {
+
+       /*************************
+        *
+        * 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':
+                           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];
+                                               }
+                                       }
+                       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':
+                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->DropTableSQL('`'.$components['TABLE'].'`');
+                       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!)
+               //$this->lastHandlerKey = $this->handler_getFromTableList($ORIG_table);
+               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)  {
+                                       // the backticks get converted to the correct quote char automatically
+                                       $fieldsKeys[$fN] = '`'.$fN.'` '.$this->compileFieldCfg($fCfg['definition'],$fN);
+                               }
+
+                               foreach($components['KEYS'] as $kN => $kCfg)    {
+                                       if ($kN == 'PRIMARYKEY')        {
+                                               foreach($kCfg as $n => $field)  {
+                                                       $fieldsKeys[$field] .= ' PRIMARY';
+                                               }
+                                               } else {
+                                               $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($components['TABLE'].'_'.$kN, $components['TABLE'], $kCfg));
+                                       }
+                               }
+
+                               // Fetch table/index generation query:
+                               $query = array_merge($GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->CreateTableSQL('`'.$components['TABLE'].'`',implode(','.chr(10), $fieldsKeys)), $indexKeys);
+                       break;
+               }
+
+               return $query;
+       }
+
+       function compileALTERTABLE($components) {
+
+               // Execute query (based on handler derived from the TABLE name which we actually know for once!)
+               //$this->lastHandlerKey = $this->handler_getFromTableList($ORIG_table);
+               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
+                       case 'native':
+                               $query[] = parent::compileALTERTABLE($components);
+                       break;
+                       case 'adodb':
+                               switch(strtoupper(str_replace(array(" ","\n","\r","\t"),'',$components['action'])))     {
+                                       case 'ADD':
+                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AddColumnSQL('`'.$components['TABLE'].'`','`'.$components['FIELD'].'` '.$this->compileFieldCfg($components['definition']));
+                                       break;
+                                       case 'CHANGE':
+                                               $query = $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->AlterColumnSQL('`'.$components['TABLE'].'`','`'.$components['FIELD'].'` '.$this->compileFieldCfg($components['definition']));
+                                       break;
+                                       case 'DROP':
+                                       case 'DROPKEY':
+                                       break;
+                                       case 'ADDKEY':
+                                       case 'ADDPRIMARYKEY':
+                                               $query.=' ('.implode(',',$components['fields']).')';
+                                       break;
+                               }
+                       break;
+               }
+               echo '<!-- ';var_dump($query);echo ' -->'.chr(10);
+
+               return $query;
+       }
+
+       /**
+        * Compile field definition
+        *
+        * @param       array           Field definition parts
+        * @return      string          Field definition string
+        */
+       function compileFieldCfg($fieldCfg,$fN='')      {
+               switch((string)$GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->lastHandlerKey]['type'])  {
+                       case 'native':
+                               $cfg = parent::compileFieldCfg($fieldCfg,$fN);
+                       break;
+                       case 'adodb':
+                       // Set type:
+                       $cfg = $GLOBALS['TYPO3_DB']->MySQLMetaType($fieldCfg['fieldType']);
+
+                       // Add value, if any:
+                       if (strlen($fieldCfg['value']) && (in_array($cfg, array('C','C2'))))    {
+                               $cfg.=' '.$fieldCfg['value'];
+                       }
+
+                       // Add additional features:
+                       if (is_array($fieldCfg['featureIndex']))        {
+
+                               // MySQL assigns DEFAULT value automatically if NOT NULL, fake this here
+                               //if(array_key_exists('NOTNULL',$fieldCfg['featureIndex']) && !array_key_exists('DEFAULT',$fieldCfg['featureIndex']) && !array_key_exists('AUTO_INCREMENT',$fieldCfg['featureIndex'])) {
+                               if(isset($fieldCfg['featureIndex']['NOTNULL']) && !isset($fieldCfg['featureIndex']['DEFAULT']) && !isset($fieldCfg['featureIndex']['AUTO_INCREMENT'])) {
+                                       $fieldCfg['featureIndex']['DEFAULT'] = array('keyword' => 'DEFAULT', 'value' => array('','\''));
+                               }
+
+                               // we handle unsigned, auto_increment and NOT NULL
+                               foreach($fieldCfg['featureIndex'] as $featureDef)       {
+                                       if($featureDef['keyword'] == 'unsigned') {
+                                               continue;
+                                       }
+                                       if($featureDef['keyword'] == 'auto_increment') {
+                                               //$cfg.=' AUTO'; removed as we handle auto_increment different now
+                                               continue;
+                                       }
+                                       if($featureDef['keyword'] == 'NOT NULL') {
+                                               if($this->checkEmptyDefaultValue($fieldCfg['featureIndex'])) // we do not have a default value or it is an empty string
+                                                       continue;
+                                               else
+                                                       $cfg.=' NOTNULL';
+                                       }
+
+                                       $cfg.=' '.$featureDef['keyword'];
+
+                                       // Add value if found:
+                                       if (is_array($featureDef['value']))     {
+                                               if(!is_numeric($featureDef['value'][0]) && empty($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;
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_sqlparser.php'])  {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_sqlparser.php']);
+}
+?>
diff --git a/typo3/sysext/dbal/doc/TODO.txt b/typo3/sysext/dbal/doc/TODO.txt
new file mode 100644 (file)
index 0000000..a185d26
--- /dev/null
@@ -0,0 +1,102 @@
+Portability issues:
+- AUTO_INCREMENT: Sequence generation is ux_t3lib_db::exec_INSERTquery(); We need to generate any unique ids for records in this function when ADOdb/PEAR is used, using other databases than MySQL. The problem is mostly that the function needs to make a lookup somewhere if the table in question has a field with auto-incremeneted values... We have no solution yet to where this information can come from
+- CLOBS/BLOBS: Update/Insert CLOBs/BLOBs in ux_t3lib_db::exec_INSERTquery()/ux_t3lib_db::exec_UPDATEquery() - this will probably be needed for some databases. In that case we will have to know which fields should be handled separately. It's unclear to me if this depends on field-type (eg. "blob" / "clob") or if it depends on the length of the input!
+
+Portability "Jokers":
+In Oracle I have experienced that an error occurs if you:
+- Insert a "" quoted string in an integer/number field - even if the value inside is a number! - so will we have to make lookups on field type to determine this?
+- Insert a string longer than the size of the field in the database (MySQL just silently accepts this...) - so will we have to evaluate all values in update/insert queries first?
+- sum(), max(), min(), count(), avg() functions in select field list? Are those available in all other DBMS?
+- simple table joins are used many places. Are those available in all other DBMS?
+
+ADOdb/PEAR implementation issues:
+- sql_fetch_assoc() and sql_fetch_row(): How will the behavior of associative keys be with other databases than MySQL? This is not solid enough yet.
+- "free-result" in ADOdb? What is it?
+- sql_insert_id(): For PEAR this is definitely not working with anything by MySQL!
+- sql_data_seek(): For PEAR this seems to have no equalent. Must be simulated?
+- sql_field_type(): Needs support for all but "native" mode.
+- admin_get_tables() / admin_get_fields() / admin_get_keys(): Needs support in ADOdb and PEAR.
+
+SQL parser issues:
+- t3lib_sqlengine: Quoting of strings is done sensitive to DB, but the PARSING of SQL and re-assembling done with t3lib_sqlengine does NOT know about quoting format! This has to be solved for other databases than MySQL... "t3lib_sqlengine" has to support parsing AND compiling of queries with different quoting methods.
+
+New Features?
+- user processing hooks implemented on tables/fields etc.
+- readOnly control on tables/handlers
+- persistent connections configured as an option per handler?
+
+General TODO:
+- Implement and test other databases with ADOdb and PEAR
+- Create any amount of management needed
+- Create documentation for other databases
+- Support for people implementing DBAL (I imagine there is a contact person per. DBMS implemented)
+
+
+
+
+
+
+
+********************
+APPENDIX: DBAL (moved to here from Core TODO.txt)
+********************
+Issues:
+- Install tool, analysing SQL files, comparing, dumping etc. How? (MetaDatabase, MetaTables)
+- case-folding?
+- reserved words (uid!!) Which R-words?
+- LIMIT. selectLimit(x,x)
+- mysql_fetch_assoc substitute (seems to be there)
+- escaping chars with special function!!!
+- datatypes? Integer not there? LOB's a problem?
+- Internal functions: AVG, SUM, count
+- mysql_num_rows() = recordCount()
+- autoinc. of numbers with GenID()
+- how about joining?
+- ALTER TABLE syntax?
+
+Analysis:
+- SUPPORT: Core (+ 'cms') will support all DBs, extension MAY support a SUBSET of DBs only.
+- EM: MySQL will be the main supported database. sql-files for install tool follows MySQL syntax. Comparison can be done if ADOdb allows us to read table/field info (will need mapping of datatypes), updates may only be done if we support it. Not important. People CAN update manually with other DBs.
+- NAMING: Reserved words and case restrictions are a real problem. For now, lets call it unacceptable. Handling of this would include 1) conversion table in ADOdb for result set assoc. key mapping AND mapping of fields in the queries!
+- ESCAPING: Escaping characters will be very annoying because we'll have to pass an array first to stripslashes, then to add DB-specific slashes, then make Query. But we can for MySQL (and similar) bypass this...
+- LOBs: Working with LOBs seems to be extremely irritating, inserting them separately (In oracle)!! How are we knowing anyways that this is a LOB? Solution might be to bypass for MySQL and for problem DBs send the UPDATE/INSERT row (must be array then!!!) through a filter which returns new row plus a blob row for update afterwards.
+- AUTO-ID: Auto-incrementing is also a BIG irritation! Currently all inserts DO NOT set the id column!!! All insert statements must include the new, correct field (at least for the problem DB's like Oracle)
+- BTW: Escaping and BLOB handling seems to require the same for all INSERTs and UPDATEs: A field_array passed to function. Auto-id may relate to this (at least it will be required all places ...)
+- SQL: Will have to split up LIMIT selects. New escaping in SELECT queries. INSERT/UPDATE from field_arrays + processing, mysql_fetch_assoc() function "pandan"
+
+API:
+SELECT: 
+- Separate LIMIT from the rest. 
+- JOINS ? Functions like AVG, SUM?
+- Escaping of search strings
+
+UPDATE/INSERT:
+- Array passed to function if not MySQL
+  Function has: possible "autoincrement" field argument; If Oracle, auto-id is handled; If Oracle, BLOB-array is returned for separate insertion.
+
+
+ORACLE does not allow us to CHANGE existing fields into something else - only create new fields, otherwise we must export/import database.
+
+Other notes:
+- Datatypes to use for integers and others? Date/Time not a problem because typo3 uses integers.
+- AVG, SUM, COUNT - will they be there?
+- I'll need access to Oracle, MSSQL, PostGres - basically the databases we are going to connect to!!!
+- JOINS???
+- Having some lookup table (not TCA, because this is very individual from site to site) telling us which database (name+brand+server) a table is coming from, if not the default database. This also means that we will have an array of databases set up (one being default)!
+
+180303 / Oracle:
+- all fields/tablenames must be quoted
+- a quoted value cannot be inserted into an integerfield!!!
+
+
+insert... "kasper"
+
+Related issues: 
+- LPE: DB/DB sync.
+
+ORACLE / DB2:
+- u: db2admin
+- p: password
+
+Also see:
+- [Kasper] "DB Abstraction" folder in Mailbox 
\ No newline at end of file
diff --git a/typo3/sysext/dbal/doc/manual.sxw b/typo3/sysext/dbal/doc/manual.sxw
new file mode 100644 (file)
index 0000000..ae14328
Binary files /dev/null and b/typo3/sysext/dbal/doc/manual.sxw differ
diff --git a/typo3/sysext/dbal/ext_emconf.php b/typo3/sysext/dbal/ext_emconf.php
new file mode 100644 (file)
index 0000000..b3b74b7
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+########################################################################
+# Extension Manager/Repository config file for ext: "dbal"
+#
+# Auto generated 27-12-2005 15:45
+#
+# Manual updates:
+# Only the data in the array - anything else is removed by next write
+########################################################################
+
+$EM_CONF[$_EXTKEY] = Array (
+       'title' => 'Database Abstraction Layer',
+       'description' => '',
+       'category' => 'be',
+       'author' => 'Karsten Dambekalns',
+       'author_email' => 'k.dambekalns@fishfarm.de',
+       'shy' => '',
+       'dependencies' => 'adodb',
+       'conflicts' => '',
+       'priority' => '',
+       'module' => 'mod1',
+       'state' => 'beta',
+       'internal' => '',
+       'uploadfolder' => 0,
+       'createDirs' => '',
+       'modify_tables' => '',
+       'clearCacheOnLoad' => 0,
+       'lockType' => '',
+       'author_company' => '',
+       'private' => '',
+       'download_password' => '',
+       'version' => '0.5.0',   // Don't modify this! Managed automatically during upload to repository.
+       '_md5_values_when_last_written' => 'a:20:{s:9:"ChangeLog";s:4:"2614";s:21:"class.ux_t3lib_db.php";s:4:"e6f3";s:28:"class.ux_t3lib_sqlengine.php";s:4:"74b9";s:28:"class.ux_t3lib_sqlparser.php";s:4:"ed68";s:12:"ext_icon.gif";s:4:"1bdc";s:17:"ext_localconf.php";s:4:"4c9c";s:15:"ext_php_api.dat";s:4:"56e0";s:14:"ext_tables.php";s:4:"427e";s:14:"ext_tables.sql";s:4:"1d3e";s:12:"doc/TODO.txt";s:4:"8ff6";s:14:"doc/manual.sxw";s:4:"d418";s:45:"handlers/class.tx_dbal_handler_openoffice.php";s:4:"fb7a";s:43:"handlers/class.tx_dbal_handler_rawmysql.php";s:4:"25f3";s:40:"handlers/class.tx_dbal_handler_xmldb.php";s:4:"df24";s:14:"mod1/clear.gif";s:4:"cc11";s:13:"mod1/conf.php";s:4:"03f8";s:14:"mod1/index.php";s:4:"65cb";s:18:"mod1/locallang.xml";s:4:"af22";s:22:"mod1/locallang_mod.xml";s:4:"d1c6";s:19:"mod1/moduleicon.gif";s:4:"8074";}',
+);
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/ext_icon.gif b/typo3/sysext/dbal/ext_icon.gif
new file mode 100644 (file)
index 0000000..b993e8a
Binary files /dev/null and b/typo3/sysext/dbal/ext_icon.gif differ
diff --git a/typo3/sysext/dbal/ext_localconf.php b/typo3/sysext/dbal/ext_localconf.php
new file mode 100644 (file)
index 0000000..d17b5cb
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+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';
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/ext_php_api.dat b/typo3/sysext/dbal/ext_php_api.dat
new file mode 100644 (file)
index 0000000..8fa9d2e
--- /dev/null
@@ -0,0 +1,864 @@
+a:2:{s:4:"meta";a:3:{s:5:"title";s:12:"DBAL package";s:5:"descr";s:0:"";s:7:"options";a:2:{s:10:"usageCount";s:1:"1";s:19:"includeCodeAbstract";s:1:"1";}}s:5:"files";a:4:{s:14:"MD5_9a0025a766";a:5:{s:8:"filename";s:21:"class.ux_t3lib_db.php";s:8:"filesize";i:43452;s:6:"header";a:5:{s:4:"text";s:35:"
+
+TYPO3 database abstraction layer
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:3:"DAT";a:29:{i:1;a:8:{s:6:"header";s:36:"class ux_t3lib_DB extends t3lib_DB {";s:5:"class";i:1;s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:35:"
+
+TYPO3 database abstraction layer
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:7:"content";a:2:{i:0;s:1311:"
+               // Internal, static:
+       var $printErrors = FALSE;                       // Enable output of SQL errors after query executions. Set through TYPO3_CONF_VARS, see init()
+       var $debug = FALSE;                                     // Enable debug mode. Set through TYPO3_CONF_VARS, see init()
+
+       var $mapping = array();                         // See manual.
+       var $table2handlerKeys = array();       // See manual.  
+       var $handlerCfg = array (                       // See manual.
+               '_DEFAULT' => array (
+                       'type' => 'native',
+                       'config' => array(
+                               'username' => '',               // Set by default (overridden)
+                               'password' => '',               // Set by default (overridden)
+                               'host' => '',                   // Set by default (overridden)
+                               'database' => '',               // Set by default (overridden)
+                               'driver' => '',                 // ONLY "adodb" / "pear" type; eg. "mysql"
+                       )
+               ),
+       );
+
+
+               // Internal, dynamic:
+       var $handlerInstance = array();                         // Contains instance of the handler objects as they are created. Exception is the native mySQL calls which are registered as an array with keys "handlerType" = "native" and "link" pointing to the link resource for the connection.
+       var $lastHandlerKey = '';                                       // Storage of the handler key of last ( SELECT) query - used for subsequent fetch-row calls etc.
+       var $lastQuery = '';                                            // Storage of last SELECT query
+
+       var $resourceIdToTableNameMap = array();        // Mapping of resource ids to table names.
+
+
+       
+       
+       
+       
+       ";i:1;i:-1;}s:12:"content_size";i:1311;s:13:"content_lines";i:33;s:6:"atLine";i:104;}i:3;a:7:{s:6:"header";s:24:"function ux_t3lib_DB() {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:109:"
+
+Constructor. 
+Creates SQL parser object and imports configuration from $TYPO3_CONF_VARS['EXTCONF']['dbal']
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:7:"content";a:2:{i:0;s:507:"               global $TYPO3_CONF_VARS;
+
+                       // Set outside configuration:
+               if (isset($TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping']))                              $this->mapping = $TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'];
+               if (isset($TYPO3_CONF_VARS['EXTCONF']['dbal']['table2handlerKeys']))    $this->table2handlerKeys = $TYPO3_CONF_VARS['EXTCONF']['dbal']['table2handlerKeys'];
+               if (isset($TYPO3_CONF_VARS[
+[...]
+ethods)
+        * These functions are extending counterparts in the parent class.
+        * 
+        **************************************/
+
+       ";i:1;i:1;}s:12:"content_size";i:1046;s:13:"content_lines";i:30;s:6:"atLine";i:144;}i:5;a:8:{s:6:"header";s:50:"function exec_INSERTquery($table,$fields_values)        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:2:{i:0;s:42:"Query Building (Overriding parent methods)";i:1;s:63:"These functions are extending counterparts in the parent class.";}s:4:"cDat";a:3:{s:4:"text";s:84:"
+
+Inserts a record for $table from the array with field/value pairs $fields_values.
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"string";i:1;s:10:"Table name";}i:1;a:2:{i:0;s:5:"array";i:1;s:191:"Field values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$insertFields" with 'fieldname'=>'value' and pass it to this function as argument.";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:67:"Result from handler, usually TRUE when success and FALSE on failure";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Do field mapping if needed:
+               if ($tableArray = $this->map_needMapping($table))       {
+               
+                               // Field mapping of array:
+                       $fields_values = $this->map_assocArray($fields_values,$tableArray);
+
+                               // Table name:
+                       if ($this->mapping[$table]['mapTableName'])     {
+                               $table = $this->mapping[$table]['mapTableName'];
+                       }
+               }
+
+                       // Select API:
+               $this->lastHandlerKey = $this
+[...]
+->printErrors && $this->sql_error())   { debug(array($this->sql_error()));     }
+               
+                       // Return output:
+               return $sqlResult;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1697;s:13:"content_lines";i:43;s:6:"atLine";i:182;}i:7;a:7:{s:6:"header";s:57:"function exec_UPDATEquery($table,$where,$fields_values) {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:31:"
+
+Updates a record from $table
+";s:5:"param";a:3:{i:0;a:2:{i:0;s:6:"string";i:1;s:18:"Database tablename";}i:1;a:2:{i:0;s:6:"string";i:1;s:107:"WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->quoteStr() yourself!";}i:2;a:2:{i:0;s:5:"array";i:1;s:191:"Field values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$updateFields" with 'fieldname'=>'value' and pass it to this function as argument.";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:67:"Result from handler, usually TRUE when success and FALSE on failure";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Do table/field mapping:
+               if ($tableArray = $this->map_needMapping($table))       {
+               
+                               // Field mapping of array:
+                       $fields_values = $this->map_assocArray($fields_values,$tableArray);
+                       
+                               // Where clause table and field mapping:
+                       $whereParts = $this->SQLparser->parseWhereClause($where);
+                       $this->map_sqlParts($whereParts,$tableArray[0]['table']);
+                       $where = $t
+[...]
+->printErrors && $this->sql_error())   { debug(array($this->sql_error()));     }
+               
+                       // Return result:
+               return $sqlResult;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1804;s:13:"content_lines";i:45;s:6:"atLine";i:234;}i:9;a:7:{s:6:"header";s:42:"function exec_DELETEquery($table,$where)        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:29:"
+
+Deletes records from table
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"string";i:1;s:18:"Database tablename";}i:1;a:2:{i:0;s:6:"string";i:1;s:107:"WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->quoteStr() yourself!";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:19:"Result from handler";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Do table/field mapping:
+               if ($tableArray = $this->map_needMapping($table))       {
+
+                               // Where clause:
+                       $whereParts = $this->SQLparser->parseWhereClause($where);
+                       $this->map_sqlParts($whereParts,$tableArray[0]['table']);
+                       $where = $this->SQLparser->compileWhereClause($whereParts);
+
+                               // Table name:
+                       if ($this->mapping[$table]['mapTableName'])     {
+                               $table = $
+[...]
+->printErrors && $this->sql_error())   { debug(array($this->sql_error()));     }
+               
+                       // Return result:
+               return $sqlResult;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1419;s:13:"content_lines";i:40;s:6:"atLine";i:287;}i:11;a:7:{s:6:"header";s:103:"function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='') {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:35:"
+
+Selects records from Data Source
+";s:5:"param";a:6:{i:0;a:2:{i:0;s:6:"string";i:1;s:101:"List of fields to select from the table. This is what comes right after "SELECT ...". Required value.";}i:1;a:2:{i:0;s:6:"string";i:1;s:89:"Table(s) from which to select. This is what comes right after "FROM ...". Required value.";}i:2;a:2:{i:0;s:6:"string";i:1;s:186:"Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->quoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!";}i:3;a:2:{i:0;s:6:"string";i:1;s:57:"Optional GROUP BY field(s), if none, supply blank string.";}i:4;a:2:{i:0;s:6:"string";i:1;s:57:"Optional ORDER BY field(s), if none, supply blank string.";}i:5;a:2:{i:0;s:6:"string";i:1;s:65:"Optional LIMIT value ([begin,]max), if none, supply blank string.";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:55:"Result from handler. Typically object from DBAL layers.";}}s:7:"content";a:2:{i:0;s:507:"
+               if ($this->debug)       $pt = t3lib_div::milliseconds();
+
+                       // Map table / field names if needed:
+               $ORIG_from_table = $from_table; // Saving table names in $ORIG_from_table since $from_table is transformed beneath:
+               if ($tableArray = $this->map_needMapping($ORIG_from_table))     {
+                       $this->map_remapSELECTQueryParts($select_fields,$from_table,$where_clause,$groupBy,$orderBy);   
+[...]
+
+       
+       /**************************************
+        *
+        * Various helper functions
+        *
+        **************************************/
+
+       ";i:1;i:1;}s:12:"content_size";i:4084;s:13:"content_lines";i:115;s:6:"atLine";i:339;}i:13;a:8:{s:6:"header";s:36:"function quoteStr($str, $table='')    {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:1:{i:0;s:24:"Various helper functions";}s:4:"cDat";a:3:{s:4:"text";s:129:"
+
+Perform context sensitive escaping of strings. This may be "addslashes()" or whatever method fits the current database driver.
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"string";i:1;s:12:"Input string";}i:1;a:2:{i:0;s:6:"string";i:1;s:143:"Table name for which to quote string. Just enter which table(s) that goes into the query. Important for detection of DBMS handler of the query!";}}s:6:"return";a:2:{i:0;s:6:"string";i:1;s:79:"Output string; Quotes (" / ') and \ will be backslashed according to DBMS used.";}}s:7:"content";a:2:{i:0;s:507:"           $this->lastHandlerKey = $this->handler_getFromTableList($table);
+               switch((string)$this->handlerCfg[$this->lastHandlerKey]['type'])        {
+                       case 'native':
+                               $str = addslashes($str);
+                       break;
+                       case 'adodb':
+                               $str = $this->handlerInstance[$this->lastHandlerKey]->qstr($str);
+                       break;
+                       case 'pear':
+                               $str = $this->handlerInstance[$this->lastHandlerKey]->quoteString
+[...]
+per functions (Overriding parent methods)
+        * (For use in your applications)
+        *
+        **************************************/
+
+       ";i:1;i:1;}s:12:"content_size";i:779;s:13:"content_lines";i:38;s:6:"atLine";i:462;}i:15;a:8:{s:6:"header";s:22:"function sql_error()    {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:2:{i:0;s:49:"SQL wrapper functions (Overriding parent methods)";i:1;s:30:"(For use in your applications)";}s:4:"cDat";a:3:{s:4:"text";s:95:"
+
+Returns the error status on the most recent sql() execution (based on $this->lastHandlerKey)
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"string";i:1;s:21:"Handler error strings";}}s:7:"content";a:2:{i:0;s:507:"
+               switch($this->handlerCfg[$this->lastHandlerKey]['type'])        {
+                       case 'native':
+                               $output = mysql_error($this->handlerInstance[$this->lastHandlerKey]['link']);
+                       break;
+                       case 'adodb':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->ErrorMsg();
+                       break;
+                       case 'pear':
+                               // PEAR returns an ERROR object if something is wrong. For other APIs the error is 
+[...]
+userdefined':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->sql_error();
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:777;s:13:"content_lines";i:20;s:6:"atLine";i:506;}i:17;a:7:{s:6:"header";s:30:"function sql_num_rows(&$res)    {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:39:"
+
+Returns the number of selected rows.
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:28:"Result pointer / DBAL object";}}s:6:"return";a:2:{i:0;s:7:"integer";i:1;s:25:"Number of resulting rows.";}}s:7:"content";a:2:{i:0;s:381:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_num_rows($res);
+                       break;
+                       case 'adodb':
+                               $output = $res->RecordCount();
+                       break;
+                       case 'pear':
+                               $output = $res->numRows();
+                       break;
+                       case 'userdefined':
+                               $output = $res->sql_num_rows();
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:381;s:13:"content_lines";i:19;s:6:"atLine";i:533;}i:19;a:7:{s:6:"header";s:33:"function sql_fetch_assoc(&$res) {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:104:"
+
+Returns an associative array that corresponds to the fetched row, or FALSE if there are no more rows.
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:52:"MySQL result pointer (of SELECT query) / DBAL object";}}s:6:"return";a:2:{i:0;s:5:"array";i:1;s:32:"Associative array of result row.";}}s:7:"content";a:2:{i:0;s:507:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_fetch_assoc($res);
+                               $tableList = $this->resourceIdToTableNameMap[(string)$res];     // Reading list of tables from SELECT query:
+                       break;
+                       case 'adodb':
+                               $output = $res->FetchRow();
+                               $tableList = $res->TYPO3_DBAL_tableList;        //
+[...]
+eList,TRUE))   {
+                               $output = $this->map_assocArray($output,$tables,1);
+                       }
+               }
+
+                       // Return result:
+               return $output;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1324;s:13:"content_lines";i:40;s:6:"atLine";i:559;}i:21;a:7:{s:6:"header";s:31:"function sql_fetch_row(&$res)  {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:144:"
+
+Returns an array that corresponds to the fetched row, or FALSE if there are no more rows.
+The array contains the values in numerical indices.
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:52:"MySQL result pointer (of SELECT query) / DBAL object";}}s:6:"return";a:2:{i:0;s:5:"array";i:1;s:23:"Array with result rows.";}}s:7:"content";a:2:{i:0;s:507:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_fetch_row($res);
+                       break;
+                       case 'adodb':
+                               $output = $res->FetchRow();
+                               
+                                       // Removing all assoc. keys. 
+                                       // Just a temporary workaround till I know how to make ADOdb return this by default... Most likely this will not 
+[...]
+TCHMODE_ORDERED);
+                       break;
+                       case 'userdefined':
+                               $output = $res->sql_fetch_row();
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:732;s:13:"content_lines";i:27;s:6:"atLine";i:607;}i:23;a:7:{s:6:"header";s:33:"function sql_free_result(&$res) {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:21:"
+
+Free result memory
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:42:"MySQL result pointer to free / DBAL object";}}s:6:"return";a:2:{i:0;s:7:"boolean";i:1;s:44:"Returns TRUE on success or FALSE on failure.";}}s:7:"content";a:2:{i:0;s:326:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_free_result($res);
+                       break;
+                       case 'adodb':
+                               # ?
+                       break;
+                       case 'pear':
+                               $res->free();
+                       break;
+                       case 'userdefined':
+                               unset($res);
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:326;s:13:"content_lines";i:19;s:6:"atLine";i:641;}i:25;a:7:{s:6:"header";s:26:"function sql_insert_id()        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:58:"
+
+Get the ID generated from the previous INSERT operation
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:7:"integer";i:1;s:36:"The uid of the last inserted record.";}}s:7:"content";a:2:{i:0;s:516:"
+               switch($this->handlerCfg[$this->lastHandlerKey]['type'])        {
+                       case 'native':
+                               $output = mysql_insert_id($this->handlerInstance[$this->lastHandlerKey]['link']);
+                       break;
+                       case 'adodb':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->Insert_ID();
+                       break;
+                       case 'pear':
+                               $output = mysql_insert_id();    // WILL NOT BE THE FINAL SOLUTION HERE!!!
+                       break;
+                       case 'userdefined':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->sql_insert_id();
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:516;s:13:"content_lines";i:18;s:6:"atLine";i:666;}i:27;a:7:{s:6:"header";s:30:"function sql_affected_rows()    {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:81:"
+
+Returns the number of rows affected by the last INSERT, UPDATE or DELETE query
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:7:"integer";i:1;s:37:"Number of rows affected by last query";}}s:7:"content";a:2:{i:0;s:477:"
+               switch($this->handlerCfg[$this->lastHandlerKey]['type'])        {
+                       case 'native':
+                               $output = mysql_affected_rows();
+                       break;
+                       case 'adodb':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->Affected_Rows();
+                       break;
+                       case 'pear':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->affectedRows();
+                       break;
+                       case 'userdefined':
+                               $output = $this->handlerInstance[$this->lastHandlerKey]->sql_affected_rows();
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:477;s:13:"content_lines";i:18;s:6:"atLine";i:690;}i:29;a:7:{s:6:"header";s:37:"function sql_data_seek(&$res,$seek)     {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:31:"
+
+Move internal result pointer
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:52:"MySQL result pointer (of SELECT query) / DBAL object";}i:1;a:2:{i:0;s:7:"integer";i:1;s:19:"Seek result number.";}}s:6:"return";a:2:{i:0;s:7:"boolean";i:1;s:44:"Returns TRUE on success or FALSE on failure.";}}s:7:"content";a:2:{i:0;s:383:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_data_seek($res,$seek);
+                       break;
+                       case 'adodb':
+                               $output = $res->Move($seek);
+                       break;
+                       case 'pear':
+                               # ??? - no idea!
+                       break;
+                       case 'userdefined':
+                               $output = $res->sql_data_seek($seek);
+                       break;
+               }
+               return $output;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:383;s:13:"content_lines";i:19;s:6:"atLine";i:716;}i:31;a:7:{s:6:"header";s:41:"function sql_field_type(&$res,$pointer) {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:50:"
+
+Get the type of the specified field in a result
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:7:"pointer";i:1;s:52:"MySQL result pointer (of SELECT query) / DBAL object";}i:1;a:2:{i:0;s:7:"integer";i:1;s:12:"Field index.";}}s:6:"return";a:2:{i:0;s:6:"string";i:1;s:45:"Returns the name of the specified field index";}}s:7:"content";a:2:{i:0;s:476:"
+               $handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType :  'native';
+               switch($handlerType)    {
+                       case 'native':
+                               $output = mysql_field_type($res,$pointer);
+                       break;
+                       case 'adodb':
+                       break;
+                       case 'pear':
+                       break;
+                       case 'userdefined':
+                               $output = $res->sql_field_type($pointer);
+                       break;
+               }
+               return $output;
+       }
+       
+
+
+
+
+
+
+
+       /**********
+        *
+        * Legacy functions, bound to _DEFAULT handler. (Overriding parent methods)
+        * Depreciated.
+        *
+        **********/
+       
+       ";i:1;i:0;}s:12:"content_size";i:476;s:13:"content_lines";i:31;s:6:"atLine";i:743;}i:33;a:8:{s:6:"header";s:26:"function sql($db,$query)        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:2:{i:0;s:72:"Legacy functions, bound to _DEFAULT handler. (Overriding parent methods)";i:1;s:12:"Depreciated.";}s:4:"cDat";a:5:{s:4:"text";s:99:"
+
+Executes query (on DEFAULT handler!)
+DEPRECIATED - use exec_* functions from this class instead!
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"string";i:1;s:13:"Database name";}i:1;a:2:{i:0;s:6:"string";i:1;s:16:"Query to execute";}}s:6:"return";a:2:{i:0;s:7:"pointer";i:1;s:14:"Result pointer";}s:5:"other";a:1:{i:0;s:12:"@depreciated";}s:11:"other_index";a:1:{s:12:"@depreciated";a:1:{i:0;s:1:" ";}}}s:7:"content";a:2:{i:0;s:40:"          return $this->sql_query($query);
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:40;s:13:"content_lines";i:3;s:6:"atLine";i:784;}i:35;a:7:{s:6:"header";s:28:"function sql_query($query)        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:99:"
+
+Executes query (on DEFAULT handler!)
+DEPRECIATED - use exec_* functions from this class instead!
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:16:"Query to execute";}}s:6:"return";a:2:{i:0;s:7:"pointer";i:1;s:28:"Result pointer / DBAL object";}s:5:"other";a:1:{i:0;s:12:"@depreciated";}s:11:"other_index";a:1:{s:12:"@depreciated";a:1:{i:0;s:1:" ";}}}s:7:"content";a:2:{i:0;s:507:"               
+               switch($this->handlerCfg['_DEFAULT']['type'])   {
+                       case 'native':
+                               $sqlResult = mysql_query($query, $this->handlerInstance['_DEFAULT']['link']);
+                       break;
+                       case 'adodb':
+                               $sqlResult = $this->handlerInstance['_DEFAULT']->Execute($query);
+                       break;
+                       case 'pear':
+                               $sqlResult = $this->handlerInstance['_DEFAULT']->query($query);
+                               $this->handlerInstance['_DE
+[...]
+errors:                
+               if ($this->printErrors && $this->sql_error())   { debug(array($this->sql_error()));     }
+               
+               return $sqlResult;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:724;s:13:"content_lines";i:23;s:6:"atLine";i:796;}i:37;a:7:{s:6:"header";s:79:"function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)   {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:258:"
+
+Opening the _DEFAULT connection handler to the database.
+This is typically done by the scripts "init.php" in the backend or "index_ts.php" in the frontend (tslib_fe->connectToMySQL())
+You wouldn't need to use this at any time - let TYPO3 core handle this.
+";s:5:"param";a:3:{i:0;a:2:{i:0;s:6:"string";i:1;s:23:"Database host IP/domain";}i:1;a:2:{i:0;s:6:"string";i:1;s:25:"Username to connect with.";}i:2;a:2:{i:0;s:6:"string";i:1;s:25:"Password to connect with.";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:32:"Returns handler connection value";}s:5:"other";a:2:{i:0;s:12:"@depreciated";i:1;s:19:"@see handler_init()";}s:11:"other_index";a:2:{s:12:"@depreciated";a:1:{i:0;s:1:" ";}s:4:"@see";a:1:{i:0;s:15:"handler_init() ";}}}s:7:"content";a:2:{i:0;s:503:"
+                       // Overriding the _DEFAULT handler configuration of username, password, localhost and database name:
+               $this->handlerCfg['_DEFAULT']['config']['username'] = $TYPO3_db_username;
+               $this->handlerCfg['_DEFAULT']['config']['password'] = $TYPO3_db_password;
+               $this->handlerCfg['_DEFAULT']['config']['host'] = $TYPO3_db_host;
+               $this->handlerCfg['_DEFAULT']['config']['database'] = TYPO3_db;
+
+                       // Initializing and output value:
+               $sqlResult = $this->handler_init('_DEFAULT');
+               return $sqlResult;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:503;s:13:"content_lines";i:12;s:6:"atLine";i:832;}i:39;a:7:{s:6:"header";s:35:"function sql_select_db($TYPO3_db)       {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:40:"
+
+Select database for _DEFAULT handler.
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:23:"Database to connect to.";}}s:6:"return";a:2:{i:0;s:7:"boolean";i:1;s:97:"Always returns true; function is obsolete, database selection is made in handler_init() function!";}s:5:"other";a:1:{i:0;s:12:"@depreciated";}s:11:"other_index";a:1:{s:12:"@depreciated";a:1:{i:0;s:1:" ";}}}s:7:"content";a:2:{i:0;s:161:"           return TRUE;
+       }
+
+
+
+
+
+
+
+
+
+
+       
+
+
+
+
+
+
+
+
+
+
+
+       
+
+
+       /************************************
+        * 
+        * Handler management
+        * 
+        **************************************/
+
+       ";i:1;i:0;}s:12:"content_size";i:161;s:13:"content_lines";i:33;s:6:"atLine";i:852;}i:41;a:8:{s:6:"header";s:47:"function handler_getFromTableList($tableList)   {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:1:{i:0;s:18:"Handler management";}s:4:"cDat";a:3:{s:4:"text";s:294:"
+
+Return the handler key pointing to an appropriate database handler as found in $this->handlerCfg array
+Notice: TWO or more tables in the table list MUST use the SAME handler key - otherwise a fatal error is thrown! (Logically, no database can possibly join two tables from separate sources!)
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:79:"Table list, eg. "pages" or "pages, tt_content" or "pages AS A, tt_content AS B"";}}s:6:"return";a:2:{i:0;s:6:"string";i:1;s:51:"Handler key (see $this->handlerCfg array) for table";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Get tables separated:
+               $tableArray = $this->SQLparser->parseFromTables($tableList);
+               
+                       // If success, traverse the tables:
+               if (is_array($tableArray) && count($tableArray))        {
+                       foreach($tableArray as $vArray) {
+                       
+                                       // Find handler key, select "_DEFAULT" if none is specifically configured:
+                               $handlerKey = $this->table2handlerKeys[$vArray['table']] ? $thi
+[...]
+handler key:
+                       return $outputHandlerKey;
+               } else {
+                       die('DBAL fatal error: No tables found: "'.$tableList.'"');
+               }
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1067;s:13:"content_lines";i:31;s:6:"atLine";i:893;}i:43;a:7:{s:6:"header";s:36:"function handler_init($handlerKey)     {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:46:"
+
+Initialize handler (connecting to database)
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:11:"Handler key";}}s:6:"return";a:2:{i:0;s:7:"boolean";i:1;s:36:"If connection went well, return true";}s:5:"other";a:1:{i:0;s:31:"@see handler_getFromTableList()";}s:11:"other_index";a:1:{s:4:"@see";a:1:{i:0;s:27:"handler_getFromTableList() ";}}}s:7:"content";a:2:{i:0;s:507:"
+                       // Find handler configuration:
+               $cfgArray = $this->handlerCfg[$handlerKey];
+               $handlerType = (string)$cfgArray['type'];
+               $output = FALSE;
+               
+               if (is_array($cfgArray))        {
+                       switch($handlerType)    {
+                               case 'native':
+                                       $link = mysql_pconnect(
+                                                                       $cfgArray['config']['host'], 
+                                                                       $cfgArray['config']['username'], 
+                                                                       $cfgArray['config']['password']
+               
+[...]
+
+
+
+
+
+
+
+
+       /************************************
+        * 
+        * Table/Field mapping
+        * 
+        **************************************/
+
+       ";i:1;i:1;}s:12:"content_size";i:2638;s:13:"content_lines";i:101;s:6:"atLine";i:932;}i:45;a:8:{s:6:"header";s:62:"function map_needMapping($tableList,$fieldMappingOnly=FALSE)  {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:1:{i:0;s:19:"Table/Field mapping";}s:4:"cDat";a:3:{s:4:"text";s:48:"
+
+Checks if mapping is needed for a table(list)
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"string";i:1;s:23:"List of tables in query";}i:1;a:2:{i:0;s:7:"boolean";i:1;s:93:"If true, it will check only if FIELDs are configured and ignore the mapped table name if any.";}}s:6:"return";a:2:{i:0;s:5:"mixed";i:1;s:107:"Returns an array of table names (parsed version of input table) if mapping is needed, otherwise just false.";}}s:7:"content";a:2:{i:0;s:342:"              $tables = $this->SQLparser->parseFromTables($tableList);
+               if (is_array($tables))  {
+                       foreach($tables as $tableCfg)   {
+                               if ($fieldMappingOnly)  {
+                                       if (is_array($this->mapping[$tableCfg['table']]['mapFieldNames']))      return $tables;
+                               } else {
+                                       if (is_array($this->mapping[$tableCfg['table']]))       return $tables;
+                               }
+                       }
+               }
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:342;s:13:"content_lines";i:12;s:6:"atLine";i:1041;}i:47;a:7:{s:6:"header";s:52:"function map_assocArray($input,$tables,$rev=FALSE)     {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:494:"
+
+Takes an associated array with field => value pairs and remaps the field names if configured for this table in $this->mapping array.
+Be careful not to map a field name to another existing fields name (although you can use this to swap fieldnames of course...:-)
+Observe mapping problems with join-results (more than one table): Joined queries should always prefix the table name to avoid problems with this.
+Observe that alias fields are not mapped of course (should not be a problem though)
+";s:5:"param";a:3:{i:0;a:2:{i:0;s:5:"array";i:1;s:29:"Input array, associative keys";}i:1;a:2:{i:0;s:5:"array";i:1;s:343:"Array of tables from the query. Normally just one table; many tables in case of a join. NOTICE: for multiple tables (with joins) there MIGHT occur trouble with fields of the same name in the two tables: This function traverses the mapping information for BOTH tables and applies mapping without checking from which table the field really came!";}i:2;a:2:{i:0;s:7:"boolean";i:1;s:145:"If true, reverse direction. Default direction is to map an array going INTO the database (thus mapping TYPO3 fieldnames to PHYSICAL field names!)";}}s:6:"return";a:2:{i:0;s:5:"array";i:1;s:43:"Output array, with mapped associative keys.";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Traverse tables from query (hopefully only one table):
+               foreach($tables as $tableCfg)   {
+                       if (is_array($this->mapping[$tableCfg['table']]['mapFieldNames']))      {
+                       
+                                       // Get the map (reversed if needed):
+                               if ($rev)       {
+                                       $theMap = array_flip($this->mapping[$tableCfg['table']]['mapFieldNames']);
+                               } else {
+                                       $theMap = $this->mapping[$tableCfg['table']]['m
+[...]
+       $input = $output;
+                       }
+               }
+
+                       // Return input array (which might have been altered in the mean time)
+               return $input;
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:950;s:13:"content_lines";i:36;s:6:"atLine";i:1065;}i:49;a:7:{s:6:"header";s:101:"function map_remapSELECTQueryParts(&$select_fields,&$from_table,&$where_clause,&$groupBy,&$orderBy)   {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:100:"
+
+Remaps table/field names in a SELECT query's parts
+Notice: All arguments are passed by reference!
+";s:5:"param";a:5:{i:0;a:2:{i:0;s:6:"string";i:1;s:101:"List of fields to select from the table. This is what comes right after "SELECT ...". Required value.";}i:1;a:2:{i:0;s:6:"string";i:1;s:88:"Table(s) from which to select. This is what comes right after "FROM ...". Require value.";}i:2;a:2:{i:0;s:6:"string";i:1;s:71:"Where clause. This is what comes right after "WHERE ...". Can be blank.";}i:3;a:2:{i:0;s:6:"string";i:1;s:17:"Group by field(s)";}i:4;a:2:{i:0;s:6:"string";i:1;s:17:"Order by field(s)";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}s:5:"other";a:1:{i:0;s:23:"@see exec_SELECTquery()";}s:11:"other_index";a:1:{s:4:"@see";a:1:{i:0;s:19:"exec_SELECTquery() ";}}}s:7:"content";a:2:{i:0;s:507:"               
+                       // Tables:
+               $tables = $this->SQLparser->parseFromTables($from_table);
+               $defaultTable = $tables[0]['table'];
+               foreach($tables as $k => $v)    {
+                       if ($this->mapping[$v['table']]['mapTableName'])        {
+                               $tables[$k]['table'] = $this->mapping[$v['table']]['mapTableName'];
+                       }
+               }       
+               $from_table = $this->SQLparser->compileFromTables($tables);
+
+                       // Where clause:
+               $wher
+[...]
+erBy);
+               $this->map_sqlParts($expFields,$defaultTable);
+               $orderBy = $this->SQLparser->compileSelectFields($expFields);
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1164;s:13:"content_lines";i:32;s:6:"atLine";i:1114;}i:51;a:7:{s:6:"header";s:54:"function map_sqlParts(&$sqlPartArray, $defaultTable)  {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:6:{s:4:"text";s:77:"
+
+Generic mapping of table/field names arrays (as parsed by t3lib_sqlengine)
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:5:"array";i:1;s:109:"Array with parsed SQL parts; Takes both fields, tables, where-parts, group and order-by. Passed by reference.";}i:1;a:2:{i:0;s:6:"string";i:1;s:66:"Default table name to assume if no table is found in $sqlPartArray";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}s:6:"access";s:7:"private";s:5:"other";a:1:{i:0;s:32:"@see map_remapSELECTQueryParts()";}s:11:"other_index";a:1:{s:4:"@see";a:1:{i:0;s:28:"map_remapSELECTQueryParts() ";}}}s:7:"content";a:2:{i:0;s:507:"
+                       // Traverse sql Part array:
+               if (is_array($sqlPartArray))    {
+                       foreach($sqlPartArray as $k => $v)      {
+
+                                       // Look for sublevel (WHERE parts only)
+                               if (is_array($sqlPartArray[$k]['sub'])) {
+                                       $this->map_sqlParts($sqlPartArray[$k]['sub'], $defaultTable);   // Call recursively!
+                               } else {
+                                               // For the field, look for table mapping (generic):
+                                       $t = $sqlPartA
+[...]
+
+
+
+
+
+
+
+
+
+
+
+
+
+       
+
+
+       /**************************************
+        *
+        * Debugging
+        *
+        **************************************/
+       
+       ";i:1;i:1;}s:12:"content_size";i:1088;s:13:"content_lines";i:49;s:6:"atLine";i:1156;}i:53;a:8:{s:6:"header";s:52:"function debugHandler($function,$execTime,$inData)    {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:11:"sectionText";a:1:{i:0;s:9:"Debugging";}s:4:"cDat";a:4:{s:4:"text";s:16:"
+
+Debug handler
+";s:5:"param";a:3:{i:0;a:2:{i:0;s:6:"string";i:1;s:49:"Function name from which this function is called.";}i:1;a:2:{i:0;s:6:"string";i:1;s:33:"Execution time in ms of the query";}i:2;a:2:{i:0;s:5:"array";i:1;s:25:"In-data of various kinds.";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}s:6:"access";s:7:"private";}s:7:"content";a:2:{i:0;s:507:"             global $TYPO3_CONF_VARS;
+               
+               switch($function)       {
+                       case 'exec_SELECTquery':
+
+                                       // Initialize:
+                               $data = array();
+                               $errorFlag = 0;
+                               $joinTable = '';
+
+                                       // Check error:
+                               if ($this->sql_error()) {
+                                       $data['sqlError'] = $this->sql_error();
+                                       $errorFlag|=1;
+                               }
+
+                                       // Get explain data:
+                               if ($TYPO3_CONF_VARS['EXTCONF']['dbal']['debugOptions']['E
+[...]
+inTable,$errorFlag);
+                       break;                  
+                       case 'exec_INSERTquery':
+                               // Filter out tx_dbal_debuglog table!!!
+                       break;
+               }
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1875;s:13:"content_lines";i:55;s:6:"atLine";i:1215;}i:55;a:4:{s:6:"header";s:55:"function debug_log($query,$ms,$data,$join,$errorFlag) {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:3:{s:4:"text";s:30:"
+
+Insert row in the log table
+";s:5:"param";a:5:{i:0;a:2:{i:0;s:6:"string";i:1;s:17:"The current query";}i:1;a:2:{i:0;s:7:"integer";i:1;s:39:"Execution time of query in milliseconds";}i:2;a:2:{i:0;s:5:"array";i:1;s:29:"Data to be stored serialized.";}i:3;a:2:{i:0;s:6:"string";i:1;s:31:"Join string if there IS a join.";}i:4;a:2:{i:0;s:7:"integer";i:1;s:13:"Error status.";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:6:"atLine";i:1281;}i:57;a:7:{s:6:"header";s:32:"function debug_explain($query)        {";s:11:"parentClass";s:11:"ux_t3lib_DB";s:4:"cDat";a:5:{s:4:"text";s:44:"
+
+Perform EXPLAIN query on DEFAULT handler!
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:12:"SELECT Query";}}s:6:"return";a:2:{i:0;s:5:"array";i:1;s:35:"The Explain result rows in an array";}s:5:"other";a:1:{i:0;s:121:"@todo     Not supporting other than the default handler? And what about DBMS of other kinds than MySQl - support for EXPLAIN?";}s:11:"other_index";a:1:{s:5:"@todo";a:1:{i:0;s:115:"Not supporting other than the default handler? And what about DBMS of other kinds than MySQl - support for EXPLAIN?";}}}s:7:"content";a:2:{i:0;s:365:"                $res = $this->sql_query('EXPLAIN '.$query);
+               
+               $output = array();
+               while($row = $this->sql_fetch_assoc($res))      {
+                       $output[] = $row;
+               }
+               return $output;
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_db.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_t3lib_db.php']);
+}
+?>";i:1;i:0;}s:12:"content_size";i:365;s:13:"content_lines";i:14;s:6:"atLine";i:1307;}}s:10:"usageCount";a:29:{s:12:"H_8f6fb71e0a";a:2:{s:24:"_searchtime_milliseconds";d:140;s:15:"_functionHeader";s:36:"class ux_t3lib_DB extends t3lib_DB {";}s:12:"H_1ed75ac0ec";a:2:{s:24:"_searchtime_milliseconds";d:27;s:15:"_functionHeader";s:24:"function ux_t3lib_DB()    {";}s:12:"H_9b291e60c2";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:24:"_searchtime_milliseconds";d:41;s:15:"_functionHeader";s:50:"function exec_INSERTquery($table,$fields_values)   {";}s:12:"H_495e478a6a";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:38;s:15:"_functionHeader";s:57:"function exec_UPDATEquery($table,$where,$fields_values)    {";}s:12:"H_7cdface6fe";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:31;s:15:"_functionHeader";s:42:"function exec_DELETEquery($table,$where)   {";}s:12:"H_01a2a95614";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:32;s:15:"_functionHeader";s:103:"function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')     {";}s:12:"H_4e4ae1f4ef";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:36;s:15:"_functionHeader";s:36:"function quoteStr($str, $table='') {";}s:12:"H_892599bebf";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:13;s:5:"TOTAL";i:13;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:13;s:5:"TOTAL";i:13;}s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:22:"function sql_error()   {";}s:12:"H_8d43f5d2ae";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:31;s:15:"_functionHeader";s:30:"function sql_num_rows(&$res)       {";}s:12:"H_5181bf7aac";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:6;s:5:"TOTAL";i:6;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:42;s:15:"_functionHeader";s:33:"function sql_fetch_assoc(&$res)    {";}s:12:"H_bccce8f7cd";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:38;s:15:"_functionHeader";s:31:"function sql_fetch_row(&$res)      {";}s:12:"H_6353c9f458";a:2:{s:24:"_searchtime_milliseconds";d:26;s:15:"_functionHeader";s:33:"function sql_free_result(&$res)  {";}s:12:"H_f3e8361680";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:33;s:15:"_functionHeader";s:26:"function sql_insert_id()   {";}s:12:"H_dd660adb4f";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:38;s:15:"_functionHeader";s:30:"function sql_affected_rows()       {";}s:12:"H_1f65efe545";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:37:"function sql_data_seek(&$res,$seek)        {";}s:12:"H_6500d2e72c";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:39;s:15:"_functionHeader";s:41:"function sql_field_type(&$res,$pointer)    {";}s:12:"H_b1e4dfc159";a:2:{s:24:"_searchtime_milliseconds";d:108;s:15:"_functionHeader";s:26:"function sql($db,$query)        {";}s:12:"H_f19a7d1301";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:24:"_searchtime_milliseconds";d:34;s:15:"_functionHeader";s:28:"function sql_query($query) {";}s:12:"H_bbcdd0ae60";a:2:{s:24:"_searchtime_milliseconds";d:27;s:15:"_functionHeader";s:79:"function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)    {";}s:12:"H_ea759c7f5c";a:2:{s:24:"_searchtime_milliseconds";d:28;s:15:"_functionHeader";s:35:"function sql_select_db($TYPO3_db)        {";}s:12:"H_7e9bf23e5c";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:24:"_searchtime_milliseconds";d:34;s:15:"_functionHeader";s:47:"function handler_getFromTableList($tableList)      {";}s:12:"H_786597a06d";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:24:"_searchtime_milliseconds";d:39;s:15:"_functionHeader";s:36:"function handler_init($handlerKey) {";}s:12:"H_6692461e04";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:24:"_searchtime_milliseconds";d:50;s:15:"_functionHeader";s:62:"function map_needMapping($tableList,$fieldMappingOnly=FALSE)       {";}s:12:"H_2c264fccae";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:52:"function map_assocArray($input,$tables,$rev=FALSE) {";}s:12:"H_2d361fc305";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:47;s:15:"_functionHeader";s:101:"function map_remapSELECTQueryParts(&$select_fields,&$from_table,&$where_clause,&$groupBy,&$orderBy)       {";}s:12:"H_c0c608ecd6";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:7;s:5:"TOTAL";i:7;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:7;s:5:"TOTAL";i:7;}s:24:"_searchtime_milliseconds";d:59;s:15:"_functionHeader";s:54:"function map_sqlParts(&$sqlPartArray, $defaultTable)       {";}s:12:"H_f1aaae87bd";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:36;s:15:"_functionHeader";s:52:"function debugHandler($function,$execTime,$inData) {";}s:12:"H_b5c67ebe7b";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:44;s:15:"_functionHeader";s:55:"function debug_log($query,$ms,$data,$join,$errorFlag)      {";}s:12:"H_4425106f29";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:32:"function debug_explain($query)     {";}}}s:14:"MD5_19aaeae789";a:5:{s:8:"filename";s:14:"mod1/index.php";s:8:"filesize";i:8372;s:6:"header";a:5:{s:4:"text";s:50:"
+
+Script class; Backend module for DBAL extension
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:3:"DAT";a:5:{i:1;a:8:{s:6:"header";s:44:"class tx_dbal_module1 extends t3lib_SCbase {";s:5:"class";i:1;s:11:"parentClass";s:15:"tx_dbal_module1";s:4:"cDat";a:5:{s:4:"text";s:50:"
+
+Script class; Backend module for DBAL extension
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:7:"content";a:2:{i:0;s:2:"
+       ";i:1;i:-1;}s:12:"content_size";i:2;s:13:"content_lines";i:1;s:6:"atLine";i:51;}i:3;a:7:{s:6:"header";s:23:"function menuConfig()       {";s:11:"parentClass";s:15:"tx_dbal_module1";s:4:"cDat";a:3:{s:4:"text";s:75:"
+
+Adds items to the ->MOD_MENU array. Used for the function menu selector.
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:7:"content";a:2:{i:0;s:138:"               $this->MOD_MENU = Array (
+                       'function' => Array (
+                               0 => $GLOBALS['LANG']->getLL('Debug_log')
+                       )
+               );
+               parent::menuConfig();
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:138;s:13:"content_lines";i:8;s:6:"atLine";i:58;}i:5;a:7:{s:6:"header";s:17:"function main()    {";s:11:"parentClass";s:15:"tx_dbal_module1";s:4:"cDat";a:3:{s:4:"text";s:67:"
+
+Main function of the module. Write the content to $this->content
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:7:"content";a:2:{i:0;s:507:"               global $BACK_PATH,$BE_USER;
+
+                       // Draw the header.
+               $this->doc = t3lib_div::makeInstance('noDoc');
+               $this->doc->backPath = $BACK_PATH;
+               $this->doc->form='<form action="" method="post">';
+               $this->doc->docType = 'xhtml_trans';
+
+                       // DBAL page title:
+               $this->content.=$this->doc->startPage($GLOBALS['LANG']->getLL('title'));
+               $this->content.=$this->doc->header($GLOBAL
+[...]
+on('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
+               }
+
+               $this->content.=$this->doc->spacer(10);
+       }
+
+       ";i:1;i:1;}s:12:"content_size";i:1006;s:13:"content_lines";i:25;s:6:"atLine";i:72;}i:7;a:4:{s:6:"header";s:25:"function printContent()  {";s:11:"parentClass";s:15:"tx_dbal_module1";s:4:"cDat";a:3:{s:4:"text";s:29:"
+
+Prints out the module HTML
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:6:"atLine";i:103;}i:9;a:7:{s:6:"header";s:24:"function printLogMgm()       {";s:11:"parentClass";s:15:"tx_dbal_module1";s:4:"cDat";a:3:{s:4:"text";s:121:"
+
+Printing the debug-log from the DBAL extension
+To enabled debugging, you will have to enabled it in the configuration!
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"string";i:1;s:12:"HTML content";}}s:7:"content";a:2:{i:0;s:507:"
+                       // Disable debugging in any case...
+               $GLOBALS['TYPO3_DB']->debug = FALSE;
+
+                       // Get cmd:
+               $cmd = (string)t3lib_div::_GP('cmd');
+               switch($cmd)    {
+                       case 'flush':
+                               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog','');
+                               $outStr = 'Log FLUSHED!';
+                       break;
+                       case 'joins':
+                       
+                                       // Query:
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table
+[...]
+/ Make instance:
+$SOBE = t3lib_div::makeInstance('tx_dbal_module1');
+$SOBE->init();
+$SOBE->main();
+$SOBE->printContent();
+
+?>";i:1;i:1;}s:12:"content_size";i:4883;s:13:"content_lines";i:167;s:6:"atLine";i:117;}}s:10:"usageCount";a:5:{s:12:"H_68ca39e043";a:4:{s:3:"ALL";a:2:{s:12:"makeinstance";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:12:"makeinstance";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:74;s:15:"_functionHeader";s:44:"class tx_dbal_module1 extends t3lib_SCbase {";}s:12:"H_759a824b85";a:4:{s:3:"ALL";a:2:{s:14:"nonObjectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:14:"nonObjectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:29;s:15:"_functionHeader";s:23:"function menuConfig()        {";}s:12:"H_9c2550bb82";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:37;s:15:"_functionHeader";s:17:"function main()   {";}s:12:"H_a337945941";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:34;s:15:"_functionHeader";s:25:"function printContent()   {";}s:12:"H_dec4fa07f3";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:37;s:15:"_functionHeader";s:24:"function printLogMgm()    {";}}}s:14:"MD5_54e319931e";a:5:{s:8:"filename";s:43:"handlers/class.tx_dbal_handler_rawmysql.php";s:8:"filesize";i:5559;s:6:"header";a:5:{s:4:"text";s:79:"
+
+Example DBAL userdefined handler class
+It simply makes pass-through of MySQL
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:3:"DAT";a:16:{i:1;a:8:{s:6:"header";s:56:"class tx_dbal_handler_rawmysql extends t3lib_sqlengine {";s:5:"class";i:1;s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:5:{s:4:"text";s:79:"
+
+Example DBAL userdefined handler class
+It simply makes pass-through of MySQL
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:7:"content";a:2:{i:0;s:3:"
+
+       ";i:1;i:-1;}s:12:"content_size";i:3;s:13:"content_lines";i:2;s:6:"atLine";i:78;}i:3;a:7:{s:6:"header";s:24:"function init($config)      {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:12:"$config: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:" }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:87;}i:5;a:7:{s:6:"header";s:50:"function exec_INSERTquery($table,$fields_values)     {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:11:"$table: ...";}i:1;a:2:{i:0;s:6:"[type]";i:1;s:19:"$fields_values: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"        }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:97;}i:7;a:7:{s:6:"header";s:57:"function exec_UPDATEquery($table,$where,$fields_values)      {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:3:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:11:"$table: ...";}i:1;a:2:{i:0;s:6:"[type]";i:1;s:11:"$where: ...";}i:2;a:2:{i:0;s:6:"[type]";i:1;s:19:"$fields_values: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"      }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:108;}i:9;a:7:{s:6:"header";s:42:"function exec_DELETEquery($table,$where)    {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:2:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:11:"$table: ...";}i:1;a:2:{i:0;s:6:"[type]";i:1;s:11:"$where: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"        }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:118;}i:11;a:7:{s:6:"header";s:94:"function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)       {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:6:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:19:"$select_fields: ...";}i:1;a:2:{i:0;s:6:"[type]";i:1;s:16:"$from_table: ...";}i:2;a:2:{i:0;s:6:"[type]";i:1;s:18:"$where_clause: ...";}i:3;a:2:{i:0;s:6:"[type]";i:1;s:13:"$groupBy: ...";}i:4;a:2:{i:0;s:6:"[type]";i:1;s:13:"$orderBy: ...";}i:5;a:2:{i:0;s:6:"[type]";i:1;s:11:"$limit: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:210:"              $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');
+               $res->result = mysql(TYPO3_db, $this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit));
+               return $res;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:210;s:13:"content_lines";i:5;s:6:"atLine";i:132;}i:13;a:7:{s:6:"header";s:22:"function sql_error()     {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"    }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:143;}i:15;a:7:{s:6:"header";s:26:"function sql_insert_id()   {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"    }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:151;}i:17;a:7:{s:6:"header";s:30:"function sql_affected_rows()       {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:5:"    }
+
+       ";i:1;i:0;}s:12:"content_size";i:5;s:13:"content_lines";i:2;s:6:"atLine";i:159;}i:19;a:7:{s:6:"header";s:28:"function sql_query($query) {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:11:"$query: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:127:"                $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');
+               $res->result = mysql_query($query);
+               return $res;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:127;s:13:"content_lines";i:5;s:6:"atLine";i:168;}i:21;a:7:{s:6:"header";s:25:"function quoteStr($str)  {";s:11:"parentClass";s:24:"tx_dbal_handler_rawmysql";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:9:"$str: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:39:"            return addslashes($str);
+       }
+}
+
+
+
+
+
+
+
+";i:1;i:0;}s:12:"content_size";i:39;s:13:"content_lines";i:10;s:6:"atLine";i:180;}i:23;a:8:{s:6:"header";s:73:"class tx_dbal_handler_rawmysql_sqlObj extends t3lib_sqlengine_resultobj {";s:5:"class";i:1;s:11:"parentClass";s:31:"tx_dbal_handler_rawmysql_sqlObj";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:59:"
+       $result = '';   // Not array here, but resource pointer.
+
+       ";i:1;i:-1;}s:12:"content_size";i:59;s:13:"content_lines";i:3;s:6:"atLine";i:195;}i:25;a:7:{s:6:"header";s:25:"function sql_num_rows()  {";s:11:"parentClass";s:31:"tx_dbal_handler_rawmysql_sqlObj";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:45:"           return mysql_num_rows($this->result);
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:45;s:13:"content_lines";i:3;s:6:"atLine";i:204;}i:27;a:7:{s:6:"header";s:28:"function sql_fetch_assoc()        {";s:11:"parentClass";s:31:"tx_dbal_handler_rawmysql_sqlObj";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:48:"           return mysql_fetch_assoc($this->result);
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:48;s:13:"content_lines";i:3;s:6:"atLine";i:213;}i:29;a:4:{s:6:"header";s:26:"function sql_fetch_row()  {";s:11:"parentClass";s:31:"tx_dbal_handler_rawmysql_sqlObj";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:6:"atLine";i:222;}i:31;a:7:{s:6:"header";s:34:"function sql_data_seek($pointer)       {";s:11:"parentClass";s:31:"tx_dbal_handler_rawmysql_sqlObj";s:4:"cDat";a:3:{s:4:"text";s:25:"
+
+[Describe function...]
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"[type]";i:1;s:13:"$pointer: ...";}}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}}s:7:"content";a:2:{i:0;s:299:"              return mysql_data_seek($this->result,$pointer);
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php'])   {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php']);
+}
+?>";i:1;i:0;}s:12:"content_size";i:299;s:13:"content_lines";i:8;s:6:"atLine";i:232;}}s:10:"usageCount";a:16:{s:12:"H_fd421af3c4";a:2:{s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:56:"class tx_dbal_handler_rawmysql extends t3lib_sqlengine {";}s:12:"H_4d3900dec7";a:8:{s:3:"ALL";a:2:{s:11:"objectUsage";i:7;s:5:"TOTAL";i:7;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_c20c57c067";a:3:{s:8:"fileName";s:19:"adodb/adodb.inc.php";s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:14:"MD5_b1efffa398";a:3:{s:8:"fileName";s:31:"adodb/drivers/adodb-ado.inc.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_46493f74c9";a:3:{s:8:"fileName";s:33:"adodb/drivers/adodb-mssql.inc.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:88;s:15:"_functionHeader";s:24:"function init($config)    {";}s:12:"H_9b291e60c2";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:24:"_searchtime_milliseconds";d:51;s:15:"_functionHeader";s:50:"function exec_INSERTquery($table,$fields_values)   {";}s:12:"H_495e478a6a";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:30;s:15:"_functionHeader";s:57:"function exec_UPDATEquery($table,$where,$fields_values)    {";}s:12:"H_7cdface6fe";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:35;s:15:"_functionHeader";s:42:"function exec_DELETEquery($table,$where)   {";}s:12:"H_1d0875c372";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:5;s:5:"TOTAL";i:5;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:34;s:15:"_functionHeader";s:94:"function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)       {";}s:12:"H_892599bebf";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:13;s:5:"TOTAL";i:13;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:13;s:5:"TOTAL";i:13;}s:24:"_searchtime_milliseconds";d:47;s:15:"_functionHeader";s:22:"function sql_error()   {";}s:12:"H_f3e8361680";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:32;s:15:"_functionHeader";s:26:"function sql_insert_id()   {";}s:12:"H_dd660adb4f";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:38;s:15:"_functionHeader";s:30:"function sql_affected_rows()       {";}s:12:"H_f19a7d1301";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:24:"_searchtime_milliseconds";d:41;s:15:"_functionHeader";s:28:"function sql_query($query) {";}s:12:"H_c8ff48212f";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:38;s:15:"_functionHeader";s:25:"function quoteStr($str)    {";}s:12:"H_71ad7f3507";a:4:{s:3:"ALL";a:2:{s:12:"makeinstance";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_54e319931e";a:3:{s:8:"fileName";s:43:"handlers/class.tx_dbal_handler_rawmysql.php";s:12:"makeinstance";i:2;s:5:"TOTAL";i:2;}s:24:"_searchtime_milliseconds";d:24;s:15:"_functionHeader";s:73:"class tx_dbal_handler_rawmysql_sqlObj extends t3lib_sqlengine_resultobj {";}s:12:"H_3788d29f7d";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:34;s:15:"_functionHeader";s:25:"function sql_num_rows()       {";}s:12:"H_2d28932c42";a:5:{s:3:"ALL";a:2:{s:11:"objectUsage";i:6;s:5:"TOTAL";i:6;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:2;s:5:"TOTAL";i:2;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:4;s:5:"TOTAL";i:4;}s:24:"_searchtime_milliseconds";d:49;s:15:"_functionHeader";s:28:"function sql_fetch_assoc() {";}s:12:"H_69ca6ff9bc";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:40;s:15:"_functionHeader";s:26:"function sql_fetch_row()   {";}s:12:"H_01d4cdbbfe";a:4:{s:3:"ALL";a:2:{s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:47;s:15:"_functionHeader";s:34:"function sql_data_seek($pointer)   {";}}}s:14:"MD5_f5ce71f488";a:5:{s:8:"filename";s:40:"handlers/class.tx_dbal_handler_xmldb.php";s:8:"filesize";i:3445;s:6:"header";a:5:{s:4:"text";s:65:"
+
+Example DBAL handler class
+Stores data in XML, not a database.
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:3:"DAT";a:4:{i:1;a:8:{s:6:"header";s:53:"class tx_dbal_handler_xmldb extends t3lib_sqlengine {";s:5:"class";i:1;s:11:"parentClass";s:21:"tx_dbal_handler_xmldb";s:4:"cDat";a:5:{s:4:"text";s:65:"
+
+Example DBAL handler class
+Stores data in XML, not a database.
+";s:5:"param";a:0:{}s:6:"return";a:2:{i:0;s:6:"[type]";i:1;s:3:"...";}s:5:"other";a:3:{i:0;s:42:"@author       Kasper Skaarhoj <kasper@typo3.com>";i:1;s:14:"@package TYPO3";i:2;s:19:"@subpackage tx_dbal";}s:11:"other_index";a:3:{s:7:"@author";a:1:{i:0;s:34:"Kasper Skaarhoj <kasper@typo3.com>";}s:8:"@package";a:1:{i:0;s:6:"TYPO3 ";}s:11:"@subpackage";a:1:{i:0;s:8:"tx_dbal ";}}}s:7:"content";a:2:{i:0;s:29:"
+       var $config = array();  
+       
+       ";i:1;i:-1;}s:12:"content_size";i:29;s:13:"content_lines";i:3;s:6:"atLine";i:63;}i:3;a:7:{s:6:"header";s:24:"function init($config)     {";s:11:"parentClass";s:21:"tx_dbal_handler_xmldb";s:4:"cDat";a:3:{s:4:"text";s:21:"
+
+Initialize handler
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:5:"array";i:1;s:23:"Configuration from DBAL";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:7:"content";a:2:{i:0;s:32:"           $this->config = $config;
+       }
+
+       ";i:1;i:0;}s:12:"content_size";i:32;s:13:"content_lines";i:3;s:6:"atLine";i:73;}i:5;a:4:{s:6:"header";s:33:"function readDataSource($table)     {";s:11:"parentClass";s:21:"tx_dbal_handler_xmldb";s:4:"cDat";a:3:{s:4:"text";s:43:"
+
+Setting table data (overriding function)
+";s:5:"param";a:1:{i:0;a:2:{i:0;s:6:"string";i:1;s:10:"Table name";}}s:6:"return";a:2:{i:0;s:4:"void";i:1;s:0:"";}}s:6:"atLine";i:83;}i:7;a:6:{s:6:"header";s:33:"function saveDataSource($table)      {";s:11:"parentClass";s:21:"tx_dbal_handler_xmldb";s:7:"content";a:2:{i:0;s:507:"               $xmlFile = t3lib_div::getFileAbsFileName($this->config['config']['tableFiles'][$table]);
+               $fI = pathinfo($xmlFile);
+
+               if ($xmlFile && @is_file($xmlFile) && strtolower($fI['extension'])=='xml')      {
+                       $storeInCharset = $GLOBALS['LANG']->charSet;
+                       $xmlValue = t3lib_div::array2xml($this->data[$table],'',0,'T3xmlDB',0,array('useIndexTagForNum'=>'rec'));
+                       $content = '<?xm
+[...]
+ldb.php'])     {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_xmldb.php']);
+}
+?>";i:1;i:1;}s:12:"content_size";i:753;s:13:"content_lines";i:16;s:6:"atLine";i:108;}}s:10:"usageCount";a:4:{s:12:"H_7236c5bbf1";a:2:{s:24:"_searchtime_milliseconds";d:90;s:15:"_functionHeader";s:53:"class tx_dbal_handler_xmldb extends t3lib_sqlengine {";}s:12:"H_4d3900dec7";a:8:{s:3:"ALL";a:2:{s:11:"objectUsage";i:7;s:5:"TOTAL";i:7;}s:14:"MD5_9a0025a766";a:3:{s:8:"fileName";s:21:"class.ux_t3lib_db.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_19aaeae789";a:3:{s:8:"fileName";s:14:"mod1/index.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_c20c57c067";a:3:{s:8:"fileName";s:19:"adodb/adodb.inc.php";s:11:"objectUsage";i:3;s:5:"TOTAL";i:3;}s:14:"MD5_b1efffa398";a:3:{s:8:"fileName";s:31:"adodb/drivers/adodb-ado.inc.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:14:"MD5_46493f74c9";a:3:{s:8:"fileName";s:33:"adodb/drivers/adodb-mssql.inc.php";s:11:"objectUsage";i:1;s:5:"TOTAL";i:1;}s:24:"_searchtime_milliseconds";d:78;s:15:"_functionHeader";s:24:"function init($config)       {";}s:12:"H_079d0245c8";a:2:{s:24:"_searchtime_milliseconds";d:28;s:15:"_functionHeader";s:33:"function readDataSource($table)  {";}s:12:"H_98b7a63b34";a:2:{s:24:"_searchtime_milliseconds";d:31;s:15:"_functionHeader";s:33:"function saveDataSource($table)  {";}}}}}
\ No newline at end of file
diff --git a/typo3/sysext/dbal/ext_tables.php b/typo3/sysext/dbal/ext_tables.php
new file mode 100644 (file)
index 0000000..3e031f5
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+if (!defined ('TYPO3_MODE'))   die ('Access denied.');
+
+if (TYPO3_MODE=='BE')  {
+       t3lib_extMgm::addModule('tools','txdbalM1','',t3lib_extMgm::extPath($_EXTKEY).'mod1/');
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/ext_tables.sql b/typo3/sysext/dbal/ext_tables.sql
new file mode 100644 (file)
index 0000000..d1812fc
--- /dev/null
@@ -0,0 +1,33 @@
+
+#
+# Table structure for table 'tx_dbal_debuglog'
+#
+CREATE TABLE tx_dbal_debuglog (
+       uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
+       tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+       beuser_id int(11) unsigned DEFAULT '0' NOT NULL,
+       script tinytext NOT NULL,
+       exec_time int(11) unsigned DEFAULT '0' NOT NULL,
+       table_join tinytext NOT NULL,
+       serdata text NOT NULL,
+       query text NOT NULL,
+       errorFlag int(11) unsigned DEFAULT '0' NOT NULL,
+       
+       PRIMARY KEY (uid),
+       KEY tstamp (tstamp)
+);
+
+#
+# Table structure for table 'tx_dbal_debuglog_where'
+#
+CREATE TABLE tx_dbal_debuglog_where (
+       uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
+       tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+       beuser_id int(11) unsigned DEFAULT '0' NOT NULL,
+       script tinytext NOT NULL,
+       tablename tinytext NOT NULL,
+       whereclause text NOT NULL,
+
+       PRIMARY KEY (uid),
+       KEY tstamp (tstamp)
+);
diff --git a/typo3/sysext/dbal/handlers/class.tx_dbal_handler_openoffice.php b/typo3/sysext/dbal/handlers/class.tx_dbal_handler_openoffice.php
new file mode 100644 (file)
index 0000000..eea7c7c
--- /dev/null
@@ -0,0 +1,234 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*  
+*  (c) 2004 Kasper Skaarhoj (kasper@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!
+***************************************************************/
+/**
+ * Contains an example DBAL handler class
+ *
+ * $Id$
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   74: class tx_dbal_handler_xmldb extends t3lib_sqlengine 
+ *   91:     function init($config, &$pObj)    
+ *  128:     function readDataSource($table)   
+ *  157:     function saveDataSource($table)   
+ *  184:     function xmlDB_writeStructure()   
+ *  193:     function xmlDB_readStructure()    
+ *
+ *              SECTION: SQL admin functions
+ *  217:     function admin_get_tables()       
+ *  242:     function admin_get_fields($tableName)     
+ *  276:     function admin_get_keys($tableName)       
+ *  314:     function admin_query($query)      
+ *
+ * TOTAL FUNCTIONS: 9
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+
+
+
+
+
+
+
+/**
+ * Example DBAL handler class
+ * Stores data in an Open Office Calc Spreadsheet
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class tx_dbal_handler_openoffice extends t3lib_sqlengine {
+
+       var $config = array();
+       var $pObj;      // Set from DBAL class.
+
+       var $spreadSheetFiles = '';
+       var $unzip;             // Object
+
+       /**
+        * Initialize handler
+        *
+        * @param       array           Configuration from DBAL
+        * @param       object          Parent object
+        * @return      boolean         True on success.
+        */
+       function init($config, &$pObj)  {
+               $this->config = $config['config'];
+
+               if (t3lib_extMgm::isLoaded('libunzipped'))      {
+
+                               // Include Unzip library:
+                       require_once(t3lib_extMgm::extPath('libunzipped').'class.tx_libunzipped.php');
+
+                               // Find database file:
+                       $sxc_file = t3lib_div::getFileAbsFileName($this->config['sxc_file']);
+                       if (@is_file($sxc_file))        {
+
+                               // Initialize Unzip object:
+                               $this->unzip = t3lib_div::makeInstance('tx_libunzipped');
+                               $this->spreadSheetFiles = $this->unzip->init($sxc_file);
+
+                               if (is_array($this->spreadSheetFiles))  {
+                                       return TRUE;
+                               } else $this->errorStatus = 'Spreadsheet could not be unzipped...?';
+                       } else $this->errorStatus = 'The Spreadsheet file "'.$sxc_file.'" was not found!';
+               } else $this->errorStatus = 'This data handler needs the extension "tx_libunzipped" to be installed!';
+
+               return FALSE;
+       }
+
+       /**
+        * Setting table data (overriding function)
+        *
+        * @param       string          Table name
+        * @return      void
+        */
+       function readDataSource($table) {
+               if (!is_array($this->spreadSheetFiles)) {
+                       die('Spreadsheet Data Source FATAL ERROR: No spreadsheet file loaded. Init() must have failed!');
+               }
+
+               $this->data[$table] = array();
+
+                               // Read content.xml:
+               $content_xml = $this->unzip->getFileFromArchive('content.xml');
+
+                       // Testing for writing back:
+               $content_xml = str_replace('Felt A1','FELT A1',$content_xml);
+
+                       // Writing file back (to database)
+               $this->unzip->putFileToArchive('content.xml', $content_xml['content']);
+
+                       // Writing ZIP content back to zip-archive file:
+               $result = $this->unzip->compileZipFile('fileadmin/dbtest_output.sxc');
+
+               debug($result);
+
+               exit;
+       }
+
+       /**
+        * Saving data source
+        *
+        * @param       string          Table name
+        * @return      boolean         True on success
+        */
+       function saveDataSource($table) {
+       }
+
+
+
+
+
+
+
+
+
+       /**************************************
+        *
+        * SQL admin functions
+        * (For use in the Install Tool and Extension Manager)
+        *
+        **************************************/
+
+       /**
+        * Returns the list of tables from the database
+        *
+        * @return      array           Tables in an array (tablename is in both key and value)
+        */
+       function admin_get_tables()     {
+
+               $whichTables = array();
+               return $whichTables;
+       }
+
+       /**
+        * Returns information about each field in the $table
+        *
+        * @param       string          Table name
+        * @return      array           Field information in an associative array with fieldname => field row
+        */
+       function admin_get_fields($tableName)   {
+               return array();
+       }
+
+       /**
+        * Returns information about each index key in the $table
+        *
+        * @param       string          Table name
+        * @return      array           Key information in a numeric array
+        */
+       function admin_get_keys($tableName)     {
+               return array();
+       }
+
+       /**
+        * 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
+        */
+       function admin_query($query)    {
+
+               $parsedQuery = $this->parseSQL($query);
+               $table = $parsedQuery['TABLE'];
+
+               if (is_array($parsedQuery))     {
+                               // Process query based on type:
+                       switch($parsedQuery['type'])    {
+                               case 'CREATETABLE':
+                               break;
+                               case 'ALTERTABLE':
+                               break;
+                               case 'DROPTABLE':
+                               break;
+                               default:
+                                       $this->errorStatus = 'Query type "'.$parsedQuery['type'].'" was not supported!';
+                               break;
+                       }
+
+               } else $this->errorStatus = 'SQL parse error: '.$parsedQuery;
+
+               return FALSE;
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_openoffice.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_openoffice.php']);
+}
+?>
diff --git a/typo3/sysext/dbal/handlers/class.tx_dbal_handler_rawmysql.php b/typo3/sysext/dbal/handlers/class.tx_dbal_handler_rawmysql.php
new file mode 100644 (file)
index 0000000..4e3524e
--- /dev/null
@@ -0,0 +1,355 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*  
+*  (c) 2004 Kasper Skaarhoj (kasper@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!
+***************************************************************/
+/**
+ * Contains an example DBAL handler class
+ *
+ * $Id$
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   86: class tx_dbal_handler_rawmysql extends t3lib_sqlengine 
+ *   99:     function init($config,&$pObj)     
+ *  123:     function exec_INSERTquery($table,$fields_values)  
+ *  135:     function exec_UPDATEquery($table,$where,$fields_values)   
+ *  146:     function exec_DELETEquery($table,$where)  
+ *  161:     function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)      
+ *  173:     function sql_error()      
+ *  182:     function sql_insert_id()  
+ *  191:     function sql_affected_rows()      
+ *  201:     function sql_query($query)        
+ *  213:     function quoteStr($str)   
+ *
+ *              SECTION: SQL admin functions
+ *  237:     function admin_get_tables()       
+ *  254:     function admin_get_fields($tableName)     
+ *  272:     function admin_get_keys($tableName)       
+ *  290:     function admin_query($query)      
+ *
+ *
+ *  308: class tx_dbal_handler_rawmysql_sqlObj extends t3lib_sqlengine_resultobj 
+ *  317:     function sql_num_rows()   
+ *  326:     function sql_fetch_assoc()        
+ *  335:     function sql_fetch_row()  
+ *  345:     function sql_data_seek($pointer)  
+ *
+ * TOTAL FUNCTIONS: 18
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+
+
+
+
+
+
+
+/**
+ * Example DBAL userdefined handler class
+ * It simply makes pass-through of MySQL
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class tx_dbal_handler_rawmysql extends t3lib_sqlengine {
+
+       var $config = array();  
+       var $link;
+       var $pObj;      // Set from DBAL class.
+
+       /**
+        * Initialize.
+        * For MySQL we will have to connect to the database and select the database.
+        * 
+        * @param       array           Configuration array from handler
+        * @param       object          Parent object.
+        * @return      boolean         True if connection and database selection worked out well.
+        */
+       function init($config,&$pObj)   {
+               $this->config = $config['config'];
+               $this->pObj = &$pObj;
+               $this->link = mysql_pconnect(
+                                                       $this->config['host'], 
+                                                       $this->config['username'], 
+                                                       $this->config['password']
+                                               );
+
+                       // Select database as well:
+               if (mysql_select_db($this->config['database'], $this->link))    {
+                       $output = TRUE;
+               }
+
+               return $output;
+       }
+
+       /**
+        * Execute INSERT query
+        * 
+        * @param       string          Table name
+        * @param       array           Field=>Value array
+        * @return      boolean         True on success
+        */
+       function exec_INSERTquery($table,$fields_values)        {
+               return mysql_query($GLOBALS['TYPO3_DB']->INSERTquery($table,$fields_values), $this->link);
+       }
+
+       /**
+        * Execute UPDATE query
+        * 
+        * @param       string          Table name
+        * @param       string          WHERE clause
+        * @param       array           Field=>Value array
+        * @return      boolean         True on success
+        */
+       function exec_UPDATEquery($table,$where,$fields_values) {
+               return mysql_query($GLOBALS['TYPO3_DB']->UPDATEquery($table,$where,$fields_values), $this->link);
+       }
+
+       /**
+        * Execute DELETE query
+        * 
+        * @param       string          Table name
+        * @param       string          WHERE clause
+        * @return      boolean         True on success
+        */
+       function exec_DELETEquery($table,$where)        {
+               return mysql_query($GLOBALS['TYPO3_DB']->DELETEquery($table,$where), $this->link);
+       }
+
+       /**
+        * 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 with addslashes() first
+        * @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          Result object
+        */
+       function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)    {
+               $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');              // Create result object
+               $this->pObj->lastQuery = $GLOBALS['TYPO3_DB']->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
+               $res->result = mysql(TYPO3_db, $this->pObj->lastQuery, $this->link);    // Execute query
+               return $res;
+       }
+
+       /**
+        * mysql_error() wrapper
+        * 
+        * @return      string          mysql_error()
+        */
+       function sql_error()    {
+               return mysql_error();
+       }
+
+       /**
+        * mysql_insert_id() wrapper
+        * 
+        * @return      integer         mysql_insert_id();
+        */
+       function sql_insert_id()        {
+               return mysql_insert_id();
+       }
+
+       /**
+        * mysql_affected_rows() wrapper
+        * 
+        * @return      integer         mysql_affected_rows()
+        */
+       function sql_affected_rows()    {
+               return mysql_affected_rows();
+       }
+
+       /**
+        * mysql_query() wrapper
+        * 
+        * @param       string          Query string
+        * @return      object          Result object
+        */
+       function sql_query($query)      {
+               $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');
+               $res->result = mysql_query($query, $this->link);
+               return $res;
+       }
+
+       /**
+        * Escape quotes in strings
+        * 
+        * @param       string          Input string
+        * @return      string          Output string
+        */
+       function quoteStr($str) {
+               return addslashes($str);
+       }
+       
+       
+       
+
+
+
+
+
+
+       /**************************************
+        *
+        * SQL admin functions
+        * (For use in the Install Tool and Extension Manager)
+        *
+        **************************************/
+
+       /**
+        * Returns the list of tables from the database, quering MySQL for it.
+        * 
+        * @return      array           Tables in an array (tablename is in both key and value)
+        */
+       function admin_get_tables()     {
+               $whichTables = array();
+               $tables_result = mysql_list_tables($this->config['database'], $this->link);
+               if (!mysql_error())     {
+                       while ($theTable = mysql_fetch_assoc($tables_result)) {
+                               $whichTables[current($theTable)] = current($theTable);
+                       }
+               }
+               return $whichTables;
+       }
+
+       /**
+        * Returns information about each field in the $table, quering MySQL for it.
+        * 
+        * @param       string          Table name
+        * @return      array           Field information in an associative array with fieldname => field row
+        */
+       function admin_get_fields($tableName)   {
+               $output = array();
+               
+               if ($columns_res = @mysql_query('SHOW columns FROM '.$tableName, $this->link))  {
+                       while($fieldRow = mysql_fetch_assoc($columns_res))      {
+                               $output[$fieldRow["Field"]] = $fieldRow;
+                       }
+               }
+
+               return $output;
+       }
+
+       /**
+        * Returns information about each index key in the $table, quering MySQL for it.
+        * 
+        * @param       string          Table name
+        * @return      array           Key information in a numeric array
+        */
+       function admin_get_keys($tableName)     {
+               $output = array();
+
+               if ($keyRes = @mysql_query('SHOW keys FROM '.$tableName, $this->link))  {
+                       while($keyRow = mysql_fetch_assoc($keyRes))     {
+                               $output[] = $keyRow;
+                       }
+               }
+
+               return $output;
+       }               
+
+       /**
+        * 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
+        */
+       function admin_query($query)    {
+               return $this->sql_query($query);
+       }       
+}
+
+
+
+
+
+
+
+/**
+ * Result object for this MySQL userdefined handler
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class tx_dbal_handler_rawmysql_sqlObj extends t3lib_sqlengine_resultobj {
+
+       var $result = '';                       // Not array here, but resource pointer.
+
+       /**
+        * mysql_num_rows() Wrapper
+        * 
+        * @return      integer         mysql_num_rows()
+        */
+       function sql_num_rows() {
+               return mysql_num_rows($this->result);
+       }
+
+       /**
+        * mysql_fetch_assoc() Wrapper
+        * 
+        * @return      array           mysql_fetch_assoc()
+        */
+       function sql_fetch_assoc()      {
+               return mysql_fetch_assoc($this->result);
+       }
+
+       /**
+        * mysql_fetch_row()    wrapper
+        * 
+        * @return      array           mysql_fetch_row()
+        */
+       function sql_fetch_row()        {
+               return mysql_fetch_row($this->result);
+       }
+
+       /**
+        * mysql_data_seek() wrapper
+        * 
+        * @param       integer         Pointer to go to.
+        * @return      boolean         mysql_data_seek()
+        */
+       function sql_data_seek($pointer)        {
+               return mysql_data_seek($this->result,$pointer);
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php'])   {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php']);
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/handlers/class.tx_dbal_handler_xmldb.php b/typo3/sysext/dbal/handlers/class.tx_dbal_handler_xmldb.php
new file mode 100644 (file)
index 0000000..fa59550
--- /dev/null
@@ -0,0 +1,424 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*  
+*  (c) 2004 Kasper Skaarhoj (kasper@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!
+***************************************************************/
+/**
+ * Contains an example DBAL handler class
+ *
+ * $Id$
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   74: class tx_dbal_handler_xmldb extends t3lib_sqlengine 
+ *   91:     function init($config, &$pObj)    
+ *  128:     function readDataSource($table)   
+ *  157:     function saveDataSource($table)   
+ *  184:     function xmlDB_writeStructure()   
+ *  193:     function xmlDB_readStructure()    
+ *
+ *              SECTION: SQL admin functions
+ *  217:     function admin_get_tables()       
+ *  242:     function admin_get_fields($tableName)     
+ *  276:     function admin_get_keys($tableName)       
+ *  314:     function admin_query($query)      
+ *
+ * TOTAL FUNCTIONS: 9
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+
+
+
+
+
+
+
+/**
+ * Example DBAL handler class
+ * Stores data in XML, not a database.
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class tx_dbal_handler_xmldb extends t3lib_sqlengine {
+
+       var $config = array();  
+       var $pObj;      // Set from DBAL class. 
+       
+       // Database Storage directory:
+       var $DBdir = '';
+       var $DBstructure = array(
+               'tables' => array()
+       );
+       
+       /**
+        * Initialize handler
+        * 
+        * @param       array           Configuration from DBAL
+        * @param       object          Parent object
+        * @return      void            
+        */
+       function init($config, &$pObj)  {
+               $this->config = $config['config'];
+               
+               $dbStorage = t3lib_div::getFileAbsFileName($this->config['DBstorageDir']);
+               if ($dbStorage && @is_dir($dbStorage) && ($dbStorage{strlen($dbStorage)-1} == '/')) { //ereg('/$',$dbStorage))  {
+                       $this->DBdir = $dbStorage;
+                       
+                               // Read structure file:
+                       if (@is_file($this->DBdir.'_STRUCTURE.xml'))    {
+                               $this->xmlDB_readStructure();
+                               if (is_array($this->DBstructure))       {
+                                       return TRUE;
+                               } else {
+                                       $this->errorStatus = 'The database structure array could not be loaded correctly. "_STRUCTURE.xml" may be corrupt';
+                               }
+                       } else {
+                               $this->xmlDB_writeStructure();
+                               if (@is_file($this->DBdir.'_STRUCTURE.xml'))    {
+                                       return TRUE;
+                               } else {
+                                       $this->errorStatus = 'The database structure file could not be created in dir "'.$dbStorage.'"';
+                               }
+                       }
+                       
+                       
+               } else $this->errorStatus = 'The database storage dir "'.$dbStorage.'" did not exist!';
+
+debug($this->errorStatus,'XMLDB connect ERROR:');              
+               return FALSE;
+       }
+
+       /**
+        * Setting table data (overriding function)
+        * 
+        * @param       string          Table name
+        * @return      void            
+        */
+       function readDataSource($table) {
+               
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+
+                       // Reading table:
+               if (is_array($this->DBstructure['tables'][$table]))     {
+                       if (!isset($this->data[$table]))        {       // Checking if it has already been read
+                               $newTableFile = 'TABLE_'.$table.'.xml';
+                               if (@is_file($this->DBdir.$newTableFile))       {
+                                       $this->data[$table] = t3lib_div::xml2array(t3lib_div::getUrl($this->DBdir.$newTableFile));
+                                       if (!is_array($this->data[$table]))             $this->data[$table] = array();
+                                       return TRUE;
+                               } else {
+                                       $this->data[$table] = array();
+                                       $this->errorStatus = 'Tablefile for "'.$table.'" not found';
+                               }
+                       }
+               } else $this->errorStatus = 'Table "'.$table.'" not found';
+       }
+
+       /**
+        * Saving data source
+        * 
+        * @param       string          Table name
+        * @return      boolean         True on success
+        */
+       function saveDataSource($table) {
+               
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+
+                       // Writing table:
+               if (is_array($this->DBstructure['tables'][$table]))     {
+                       $newTableFile = 'TABLE_'.$table.'.xml';
+                       if (t3lib_div::getFileAbsFileName($this->DBdir.$newTableFile) && @is_file($this->DBdir.$newTableFile))  {
+
+                               $storeInCharset = $GLOBALS['LANG']->charSet;
+                               $xmlValue = t3lib_div::array2xml($this->data[$table],'',0,'T3xmlDB',0,array('useIndexTagForNum'=>'rec'));
+                               $content = '<?xml version="1.0" encoding="'.$storeInCharset.'" standalone="yes" ?>'.chr(10).$xmlValue;
+                               t3lib_div::writeFile($this->DBdir.$newTableFile,$content);
+
+                               return TRUE;
+                       } else $this->errorStatus = 'Tablefile for "'.$table.'" not found';
+               } else $this->errorStatus = 'Table "'.$table.'" not found';
+       }
+
+       /**
+        * Writing database structure
+        * 
+        * @return      void
+        */
+       function xmlDB_writeStructure() {
+               t3lib_div::writeFile($this->DBdir.'_STRUCTURE.xml', t3lib_div::array2xml($this->DBstructure,'',0,'T3xmlDBStructure',0,array('useIndexTagForNum'=>'item')));
+       }
+
+       /**
+        * Reading database structure
+        * 
+        * @return      void
+        */
+       function xmlDB_readStructure()  {
+               $this->DBstructure = t3lib_div::xml2array(t3lib_div::getUrl($this->DBdir.'_STRUCTURE.xml'));
+       }       
+       
+       
+       
+
+
+
+
+
+
+       /**************************************
+        *
+        * SQL admin functions
+        * (For use in the Install Tool and Extension Manager)
+        *
+        **************************************/
+
+       /**
+        * Returns the list of tables from the database
+        * 
+        * @return      array           Tables in an array (tablename is in both key and value)
+        */
+       function admin_get_tables()     {
+               
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+
+               $whichTables = array();
+               
+                       // Traverse tables:
+               if (is_array($this->DBstructure['tables']))     {
+                       foreach($this->DBstructure['tables'] as $tableName => $tableInfo)       {
+                               $whichTables[$tableName] = $tableName;
+                       }
+               }
+
+               return $whichTables;
+       }
+
+       /**
+        * Returns information about each field in the $table
+        * 
+        * @param       string          Table name
+        * @return      array           Field information in an associative array with fieldname => field row
+        */
+       function admin_get_fields($tableName)   {
+               
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+
+               $output = array();
+
+                       // Traverse fields in table:
+               if (is_array($this->DBstructure['tables'][$tableName]) && is_array($this->DBstructure['tables'][$tableName]['FIELDS'])) {
+                       foreach($this->DBstructure['tables'][$tableName]['FIELDS'] as $fieldName => $fieldInfo) {
+                               $output[$fieldName] = array(
+                                       'Field' => $fieldName,
+                                       'Type' => $fieldInfo['definition']['fieldType'].
+                                                                       ($fieldInfo['definition']['value']?'('.$fieldInfo['definition']['value'].')':'').
+                                                                       (isset($fieldInfo['definition']['featureIndex']['UNSIGNED']) ? ' '.$fieldInfo['definition']['featureIndex']['UNSIGNED']['keyword'] : ''),
+                                       'Null' => isset($fieldInfo['definition']['featureIndex']['NOTNULL']) ? '' : 'Yes',
+                                       'Key' => '',
+                                       'Default' => $fieldInfo['definition']['featureIndex']['DEFAULT']['value'][0],
+                                       'Extra' => isset($fieldInfo['definition']['featureIndex']['AUTO_INCREMENT']) ? 'auto_increment' : '',
+                               );
+                       }
+               }
+
+               return $output;
+       }
+
+       /**
+        * Returns information about each index key in the $table
+        * 
+        * @param       string          Table name
+        * @return      array           Key information in a numeric array
+        */
+       function admin_get_keys($tableName)     {
+
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+
+               $output = array();
+
+                       // Traverse fields in table:
+               if (is_array($this->DBstructure['tables'][$tableName]) && is_array($this->DBstructure['tables'][$tableName]['KEYS']))   {
+                       foreach($this->DBstructure['tables'][$tableName]['KEYS'] as $keyName => $keyInfo)       {
+                               foreach($keyInfo as $seq => $keyField)  {
+                                       $output[] = array(
+                                               'Table' => $tableName,
+                                               'Non_unique' => ($keyName=='PRIMARYKEY' ? 0 : 1),
+                                               'Key_name' => ($keyName=='PRIMARYKEY' ? 'PRIMARY' : $keyName),
+                                               'Seq_in_index' => $seq+1,
+                                               'Column_name' => $keyField,
+                                               'Collation' => 'A',
+                                               'Cardinality' => '',
+                                               'Sub_part' => '',
+                                               'Packed' => '',
+                                               'Comment' => '',
+                                       );
+                               }
+                       }
+               }
+
+               return $output;
+       }
+       
+       /**
+        * 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
+        */
+       function admin_query($query)    {
+               
+               if (!$this->DBdir)      {
+                       $this->errorStatus = 'XMLdatabase not connected';
+                       return FALSE;
+               }
+               
+               $parsedQuery = $this->parseSQL($query);
+               $table = $parsedQuery['TABLE'];
+               
+               if (is_array($parsedQuery))     {
+                               // Process query based on type:
+                       switch($parsedQuery['type'])    {
+                               case 'CREATETABLE':
+                                       if (!is_array($this->DBstructure['tables'][$table]))    {
+                                               $newTableFile = 'TABLE_'.$table.'.xml';
+                                               if (!@is_file($this->DBdir.$newTableFile))      {
+
+                                                               // Write table file:
+                                                       t3lib_div::writeFile($this->DBdir.$newTableFile, '');   // Create file
+                                                       if (@is_file($this->DBdir.$newTableFile))       {
+                                                                       
+                                                                       // Set and write structure
+                                                               if (!is_array($this->DBstructure['tables']))    $this->DBstructure['tables']=array();
+                                                               $this->DBstructure['tables'][(string)$table] = $parsedQuery;    // I have some STRANGE behaviours with this variable - had to do this trick to make it work!
+
+                                                               $this->xmlDB_writeStructure();
+                                                               return TRUE;
+                                                       } else $this->errorStatus = 'Table file "'.$this->DBdir.$newTableFile.'" could not be created! Cannot create table!';
+                                               } else $this->errorStatus = 'Table file "'.$this->DBdir.$newTableFile.'" already exists! Cannot create table!';
+                                       } else $this->errorStatus = 'Table "'.$table.'" already exists!';
+                               break;
+                               case 'ALTERTABLE':
+                                       if (is_array($this->DBstructure['tables'][$table]))     {
+                                               switch($parsedQuery['action'])  {
+                                                       case 'ADD':
+                                                               if (!is_array($this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['FIELD']]))   {
+                                                                       $this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['FIELD']]['definition'] = $parsedQuery['definition'];       // Adding field in the end of list.
+                                                                       $this->xmlDB_writeStructure();
+                                                                       return TRUE;
+                                                               
+                                                                       // TODO: Should traverse all data an add that field in arrays!
+                                                               } else $this->errorStatus = 'Field "'.$parsedQuery['FIELD'].'" already exists!';
+                                                       break;
+                                                       case 'CHANGE':
+                                                               if (is_array($this->DBstructure['tables'][$table]['FIELDS']))   {
+                                                                       if (is_array($this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['FIELD']]))    {
+                                                                               $newFieldInfo = array();
+                                                                               foreach($this->DBstructure['tables'][$table]['FIELDS'] as $fieldName => $fieldDefinition)       {
+                                                                                       if (!strcmp($fieldName,$parsedQuery['FIELD']))  {
+                                                                                       
+                                                                                                       // New fieldname?
+                                                                                               if ($parsedQuery['newField'])   {
+                                                                                                       if (!is_array($this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['newField']]))        {
+                                                                                                               $fieldName = $parsedQuery['newField'];
+                                                                                                       } else {
+                                                                                                               $this->errorStatus = 'A field in the table was already named "'.$parsedQuery['newField'].'"';
+                                                                                                               return FALSE;
+                                                                                                       }
+                                                                                               }
+                                                                                                       // Set new field definition:
+                                                                                               $fieldDefinition['definition'] = $parsedQuery['definition'];
+                                                                                       }
+                                                                                       
+                                                                                               // Set the whole thing in new var:
+                                                                                       $newFieldInfo[$fieldName] = $fieldDefinition;
+                                                                               }
+                                                                               $this->DBstructure['tables'][$table]['FIELDS'] = $newFieldInfo;
+                                                                               $this->xmlDB_writeStructure();
+                                                                               return TRUE;
+                                                               
+                                                                               // TODO: Should traverse all data an remove that field in arrays!
+                                                                       } else $this->errorStatus = 'Field "'.$parsedQuery['FIELD'].'" does not exist!';
+                                                               } else $this->errorStatus = 'There are not fields in the table - strange!';
+                                                       break;
+                                                       case 'DROP':
+                                                               if (is_array($this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['FIELD']]))    {
+                                                                       unset($this->DBstructure['tables'][$table]['FIELDS'][$parsedQuery['FIELD']]);   // Removing it...
+                                                                       $this->xmlDB_writeStructure();
+                                                                       return TRUE;
+                                                               
+                                                                       // TODO: Should traverse all data an remove that field in arrays!
+                                                               } else $this->errorStatus = 'Field "'.$parsedQuery['FIELD'].'" does not exist!';
+                                                       break;
+                                               }
+                                       } else $this->errorStatus = 'Table "'.$table.'" does not exist!';
+                               break;
+                               case 'DROPTABLE':
+
+                                               // TODO:
+                                       debug($parsedQuery);
+                                       
+                                       
+                               break;
+                               default:
+                                       $this->errorStatus = 'Query type "'.$parsedQuery['type'].'" was not supported!';
+                               break;
+                       }
+                       
+               } else $this->errorStatus = 'SQL parse error: '.$parsedQuery;
+
+               return FALSE;
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_xmldb.php'])      {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_xmldb.php']);
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/mod1/clear.gif b/typo3/sysext/dbal/mod1/clear.gif
new file mode 100644 (file)
index 0000000..9ed1269
Binary files /dev/null and b/typo3/sysext/dbal/mod1/clear.gif differ
diff --git a/typo3/sysext/dbal/mod1/conf.php b/typo3/sysext/dbal/mod1/conf.php
new file mode 100644 (file)
index 0000000..dabae35
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+       // DO NOT REMOVE OR CHANGE THESE 3 LINES:
+define('TYPO3_MOD_PATH', 'sysext/dbal/mod1/');
+$BACK_PATH='../../../';
+$MCONF['name']='tools_txdbalM1';
+
+       
+$MCONF['access']='admin';
+$MCONF['script']='index.php';
+
+$MLANG['default']['tabs_images']['tab'] = 'moduleicon.gif';
+$MLANG['default']['ll_ref']='LLL:EXT:dbal/mod1/locallang_mod.xml';
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/mod1/index.php b/typo3/sysext/dbal/mod1/index.php
new file mode 100644 (file)
index 0000000..7b2bb25
--- /dev/null
@@ -0,0 +1,552 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2004 Kasper Skaarhoj (kasper@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.
+*
+*  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!
+***************************************************************/
+/**
+ * Module 'DBAL Debug' for the 'dbal' extension.
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+
+
+
+       // DEFAULT initialization of a module [BEGIN]
+unset($MCONF);
+require ('conf.php');
+require ($BACK_PATH.'init.php');
+require ($BACK_PATH.'template.php');
+$LANG->includeLLFile('EXT:dbal/mod1/locallang.xml');
+require_once (PATH_t3lib.'class.t3lib_scbase.php');
+$BE_USER->modAccess($MCONF,1); // This checks permissions and exits if the users has no permission for entry.
+       // DEFAULT initialization of a module [END]
+
+
+
+
+
+/**
+ * Script class; Backend module for DBAL extension
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_dbal
+ */
+class tx_dbal_module1 extends t3lib_SCbase {
+
+       /**
+        * Adds items to the ->MOD_MENU array. Used for the function menu selector.
+        *
+        * @return      void
+        */
+       function menuConfig()   {
+               $this->MOD_MENU = Array (
+                       'function' => Array (
+                               0 => $GLOBALS['LANG']->getLL('Debug_log'),
+                               'info' => $GLOBALS['LANG']->getLL('Cached_info'),
+                               'sqlcheck' => $GLOBALS['LANG']->getLL('SQL_check'),
+                       )
+               );
+               parent::menuConfig();
+       }
+
+       /**
+        * Main function of the module. Write the content to $this->content
+        *
+        * @return      void
+        */
+       function main() {
+               global $BACK_PATH,$BE_USER;
+
+                       // Clean up settings:
+               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
+
+                       // Draw the header.
+               $this->doc = t3lib_div::makeInstance('noDoc');
+               $this->doc->backPath = $BACK_PATH;
+               $this->doc->form='<form action="" method="post">';
+               $this->doc->docType = 'xhtml_trans';
+
+                       // JavaScript
+               $this->doc->JScode = $this->doc->wrapScriptTags('
+                               script_ended = 0;
+                               function jumpToUrl(URL) {       //
+                                       document.location = URL;
+                               }
+                       ');
+
+                       // DBAL page title:
+               $this->content.=$this->doc->startPage($GLOBALS['LANG']->getLL('title'));
+               $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('title'));
+               $this->content.=$this->doc->spacer(5);
+               $this->content.=$this->doc->section('',$this->doc->funcMenu('',t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'])));
+
+                       // Debug log:
+               switch($this->MOD_SETTINGS['function']) {
+                   case 'info':
+                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Cached_info'), $this->printCachedInfo());
+                       break;
+                   case 'sqlcheck':
+                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('SQL_check'), $this->printSqlCheck());
+                       break;
+                   case 0:
+                       $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('Debug_log'), $this->printLogMgm());
+                       break;
+               }
+
+                       // ShortCut
+               if ($BE_USER->mayMakeShortcut())        {
+                       $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
+               }
+
+               $this->content.=$this->doc->spacer(10);
+       }
+
+       /**
+        * Prints out the module HTML
+        *
+        * @return      void
+        */
+       function printContent() {
+               global $SOBE;
+
+               $this->content.=$this->doc->middle();
+               $this->content.=$this->doc->endPage();
+               echo $this->content;
+       }
+
+       function printSqlCheck()        {
+               $input = t3lib_div::_GP('tx_dbal');
+
+               $out = '
+                       <form name="sql_check" action="index.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
+                       <script type="text/javascript">
+/*<![CDATA[*/
+function updateQryForm(s) {
+       document.getElementById(\'tx-dbal-result\').style.display = \'none\';
+       switch(s) {
+       case \'SELECT\':
+               document.getElementById(\'tx-dbal-qryfields\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
+       break;
+       case \'INSERT\':
+               document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryinto\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
+       break;
+       case \'UPDATE\':
+               document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
+       break;
+       case \'DELETE\':
+               document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
+               document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
+               document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
+       break;
+       }
+}
+/*]]>*/
+                               </script>
+           <table>
+           <tr class="tableheader bgColor5"><th colspan="2">Easy SQL check</th></tr>
+           <tr><td colspan="2">
+           <select name="tx_dbal[QUERY]"size="1" onchange="updateQryForm(this.options[this.selectedIndex].value)">
+            <option value="SELECT" '.($input['QUERY']=='SELECT'? 'selected="selected"' : '').'>SELECT</option>
+            <option value="INSERT" '.($input['QUERY']=='INSERT'? 'selected="selected"' : '').'>INSERT</option>
+            <option value="UPDATE" '.($input['QUERY']=='UPDATE'? 'selected="selected"' : '').'>UPDATE</option>
+            <option value="DELETE" '.($input['QUERY']=='DELETE' ? 'selected="selected"' : '').'">DELETE</option>
+           </select>
+           </td></tr>
+           <tr id="tx-dbal-qryupdate" style="display:none;"><td></td><td><input name="tx_dbal[UPDATE]" value="'.$input['UPDATE'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qryfields"><td></td><td><input name="tx_dbal[FIELDS]" value="'.$input['FIELDS'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qryinsertvalues" style="display:none;"><td></td><td><textarea name="tx_dbal[INSERTVALUES]" cols="30" rows="4">'.$input['INSERTVALUES'].'</textarea></td></tr>
+           <tr id="tx-dbal-qryupdatevalues" style="display:none;"><th>SET</th><td><textarea name="tx_dbal[UPDATEVALUES]" cols="30" rows="4">'.$input['UPDATEVALUES'].'</textarea></td></tr>
+           <tr id="tx-dbal-qryfrom"><th>FROM</th><td><input name="tx_dbal[FROM]" value="'.$input['FROM'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qryinto" style="display:none;"><th>INTO</th><td><input name="tx_dbal[INTO]" value="'.$input['INTO'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qrywhere"><th>WHERE</th><td><input name="tx_dbal[WHERE]" value="'.$input['WHERE'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qrygroup"><th>GROUP BY</th><td><input name="tx_dbal[GROUP]" value="'.$input['GROUP'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qryorder"><th>ORDER BY</th><td><input name="tx_dbal[ORDER]" value="'.$input['ORDER'].'" type="text" size="30" maxsize="100" /></td></tr>
+           <tr id="tx-dbal-qrylimit"><th>LIMIT</th><td><input name="tx_dbal[LIMIT]" value="'.$input['LIMIT'].'" type="text" size="30" maxsize="100" /></td></tr>
+                       <tr><td></td><td style="text-align:right;"><input type="submit" value="CHECK" /></td></tr>
+                       <script type="text/javascript">
+/*<![CDATA[*/
+updateQryForm(\''.$input['QUERY'].'\');
+/*]]>*/
+                               </script>
+                       ';
+
+                       $out .= '<tr id="tx-dbal-result" class="bgColor4"><th>Result:</th><td>';
+                       switch($input['QUERY']) {
+                               case 'SELECT';
+                                       $qry = $GLOBALS['TYPO3_DB']->SELECTquery($input['FIELDS'],$input['FROM'],$input['WHERE'],$input['GROUP'],$input['ORDER'],$input['LIMIT']);
+                               break;
+                               case 'INSERT';
+                                       $qry = $GLOBALS['TYPO3_DB']->INSERTquery($input['INTO'],$this->createFieldsValuesArray($input['INSERTVALUES']));
+                               break;
+                               case 'UPDATE';
+                                       $qry = $GLOBALS['TYPO3_DB']->UPDATEquery($input['UPDATE'],$input['WHERE'],$this->createFieldsValuesArray($input['UPDATEVALUES']));
+                               break;
+                               case 'DELETE';
+                                       $qry = $GLOBALS['TYPO3_DB']->DELETEquery($input['FROM'],$input['WHERE']);
+                               break;
+                       }
+                       $out .= '<pre>'.htmlspecialchars($qry).'</pre></td></tr>';
+
+               $out .= '
+                       <tr class="tableheader bgColor5"><th colspan="2">RAW SQL check</th></tr>
+                       <tr><td colspan="2" style="text-align:right;"><textarea name="tx_dbal[RAWSQL]" cols="60" rows="5">'.$input['RAWSQL'].'</textarea><br /><input type="submit" value="CHECK" /></td></tr>';
+               if(!empty($input['RAWSQL'])) {
+                       $out .= '<tr class="bgColor4">';
+                       $parseResult = $GLOBALS['TYPO3_DB']->SQLparser->parseSQL($input['RAWSQL']);
+                       if (is_array($parseResult))     {
+                               $newQuery = $GLOBALS['TYPO3_DB']->SQLparser->compileSQL($parseResult);
+                               $testResult = $GLOBALS['TYPO3_DB']->SQLparser->debug_parseSQLpartCompare($input['RAWSQL'], $newQuery);
+                               if (!is_array($testResult))     {
+                                       $out .= '<td colspan="2">'.$newQuery;
+                               } else {
+                                       $out .= '<td colspan="2">'.htmlspecialchars($testResult[0]).'</td></tr>
+                                       <tr><th>Error:</th><td style="border:2px solid #f00;">Input query did not match the parsed and recompiled query exactly (not observing whitespace):<br />'.htmlspecialchars($testResult[1]);
+                               }
+                       } else {
+                               $out .= '<th>Result:</th><td style="border:2px solid #f00;">'.$parseResult;
+                       }
+                       $out .='</td></tr>';
+               }
+
+               $out .='</table></form>';
+               return $out;
+       }
+
+       function createFieldsValuesArray($in) {
+               $ret = array();
+               $in = explode(chr(10),$in);
+               foreach ($in as $v) {
+                       $fv = explode('=',$v);
+                       $ret[$fv[0]] = $fv[1];
+               }
+
+               return $ret;
+       }
+
+       function printCachedInfo()      {
+           // Get cmd:
+           if((string)t3lib_div::_GP('cmd') == 'clear') {
+               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
+               $GLOBALS['TYPO3_DB']->cacheFieldInfo();
+           }
+
+           $out = '<table border="1" cellspacing="0"><caption>auto_increment</caption><tbody><tr><th>Table</th><th>Field</th></tr>';
+           foreach($GLOBALS['TYPO3_DB']->cache_autoIncFields as $table => $field) {
+               $out .= '<tr>';
+               $out .= '<td>'.$table.'</td>';
+               $out .= '<td>'.$field.'</td>';
+               $out .= '</tr>';
+           }
+           $out .= '</tbody></table>';
+           $out .= $this->doc->spacer(5);
+           $out .= '<table border="1" cellspacing="0"><caption>Primary keys</caption><tbody><tr><th>Table</th><th>Field(s)</th></tr>';
+           foreach($GLOBALS['TYPO3_DB']->cache_primaryKeys as $table => $field) {
+               $out .= '<tr>';
+               $out .= '<td>'.$table.'</td>';
+               $out .= '<td>'.$field.'</td>';
+               $out .= '</tr>';
+           }
+           $out .= '</tbody></table>';
+           $out .= $this->doc->spacer(5);
+           $out .= '<table border="1" cellspacing="0"><caption>Field types</caption><tbody><tr><th colspan="3">Table</th></tr><tr><th>Field</th><th>Type</th><th>Metatype</th><th>NOT NULL</th></th></tr>';
+           foreach($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fields) {
+               $out .= '<th colspan="3">'.$table.'</th>';
+               foreach($fields as $field => $data) {
+                   $out .= '<tr>';
+                   $out .= '<td>'.$field.'</td>';
+                   $out .= '<td>'.$data['type'].'</td>';
+                   $out .= '<td>'.$data['metaType'].'</td>';
+                   $out .= '<td>'.$data['notnull'].'</td>';
+                   $out .= '</tr>';
+               }
+           }
+           $out .= '</tbody></table>';
+
+           $menu = '<a href="index.php?cmd=clear">CLEAR DATA</a><hr />';
+
+           return $menu.$out;
+       }
+
+       /**
+        * Printing the debug-log from the DBAL extension
+        * To enabled debugging, you will have to enabled it in the configuration!
+        *
+        * @return      string          HTML content
+        */
+       function printLogMgm()  {
+
+                       // Disable debugging in any case...
+               $GLOBALS['TYPO3_DB']->debug = FALSE;
+
+                       // Get cmd:
+               $cmd = (string)t3lib_div::_GP('cmd');
+               switch($cmd)    {
+                       case 'flush':
+                               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog','');
+                               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog_where','');
+                               $outStr = 'Log FLUSHED!';
+                       break;
+                       case 'joins':
+
+                                       // Query:
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table_join,exec_time,query,script','tx_dbal_debuglog','table_join!=\'\'', 'table_join,script,exec_time,query');
+
+                                       // Init vars in which to pick up the query result:
+                               $tableIndex = array();
+                               $tRows = array();
+                               $tRows[] = '
+                                       <tr>
+                                               <td>Execution time</td>
+                                               <td>Table joins</td>
+                                               <td>Script</td>
+                                               <td>Query</td>
+                                       </tr>';
+
+                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                       $tableArray = $GLOBALS['TYPO3_DB']->SQLparser->parseFromTables($row['table_join']);
+
+                                               // Create table name index:
+                                       foreach($tableArray as $a)      {
+                                               foreach($tableArray as $b)      {
+                                                       if ($b['table']!=$a['table'])   {
+                                                               $tableIndex[$a['table']][$b['table']]=1;
+                                                       }
+                                               }
+                                       }
+
+                                               // Create output row
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>'.htmlspecialchars($row['exec_time']).'</td>
+                                                       <td>'.htmlspecialchars($row['table_join']).'</td>
+                                                       <td>'.htmlspecialchars($row['script']).'</td>
+                                                       <td>'.htmlspecialchars($row['query']).'</td>
+                                               </tr>';
+                               }
+
+                                       // Printing direct joins:
+                               $outStr.= '<h4>Direct joins:</h4>'.t3lib_div::view_array($tableIndex);
+
+
+                                       // Printing total dependencies:
+                               foreach($tableIndex as $priTable => $a) {
+                                       foreach($tableIndex as $tableN => $v)   {
+                                               foreach($v as $tableP => $vv)   {
+                                                       if ($tableP == $priTable)       {
+                                                               $tableIndex[$priTable] = array_merge($v, $a);
+                                                       }
+                                               }
+                                       }
+                               }
+                               $outStr.= '<h4>Total dependencies:</h4>'.t3lib_div::view_array($tableIndex);
+
+                                       // Printing data rows:
+                               $outStr.= '
+                                       <table border="1" cellspacing="0">'.implode('',$tRows).'
+                                       </table>';
+                       break;
+                       case 'errors':
+
+                                       // Query:
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('serdata,exec_time,query,script','tx_dbal_debuglog','errorFlag>0','','tstamp DESC');
+
+                                       // Init vars in which to pick up the query result:
+                               $tRows = array();
+                               $tRows[] = '
+                                       <tr>
+                                               <td>Execution time</td>
+                                               <td>Error data</td>
+                                               <td>Script</td>
+                                               <td>Query</td>
+                                       </tr>';
+
+                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                               // Create output row
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>'.htmlspecialchars($row['exec_time']).'</td>
+                                                       <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
+                                                       <td>'.htmlspecialchars($row['script']).'</td>
+                                                       <td>'.htmlspecialchars($row['query']).'</td>
+                                               </tr>';
+                               }
+
+                                       // Printing data rows:
+                               $outStr.= '
+                                       <table border="1" cellspacing="0">'.implode('',$tRows).'
+                                       </table>';
+                       break;
+                       case 'parsing':
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('query,serdata','tx_dbal_debuglog','errorFlag&2=2');
+                               $tRows = array();
+                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                               // Create output row
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>'.htmlspecialchars($row['query']).'</td>
+                                               </tr>';
+                               }
+
+                                       // Printing data rows:
+                               $outStr.= '
+                                       <table border="1" cellspacing="0">'.implode('',$tRows).'
+                                       </table>';
+                       break;
+                       case 'where':
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script,tablename,whereclause','tx_dbal_debuglog_where','','','tstamp DESC');
+                               $tRows = array();
+                               $tRows[] = '
+                                       <tr>
+                                               <td>Time</td>
+                                               <td>Script</td>
+                                               <td>Table</td>
+                                               <td>WHERE clause</td>
+                                       </tr>';
+                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
+                                                       <td>'.htmlspecialchars($row['script']).'</td>
+                                                       <td>'.htmlspecialchars($row['tablename']).'</td>
+                                                       <td>'.str_replace(array('\'\'','""'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>','<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>'), htmlspecialchars($row['whereclause'])).'</td>
+                                               </tr>';
+                               }
+
+                               $outStr = '
+                                       <table border="1" cellspacing="0">'.implode('',$tRows).'
+                                       </table>';
+                       break;
+                       default:
+
+                                       // Look for request to view specific script exec:
+                               $specTime = t3lib_div::_GP('specTime');
+
+                               if ($specTime)  {
+                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dbal_debuglog','tstamp='.intval($specTime));
+                                       $tRows = array();
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>Execution time</td>
+                                                       <td>Error</td>
+                                                       <td>Table joins</td>
+                                                       <td>Data</td>
+                                                       <td>Query</td>
+                                               </tr>';
+                                       while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                               $tRows[] = '
+                                                       <tr>
+                                                               <td>'.htmlspecialchars($row['exec_time']).'</td>
+                                                               <td>'.($row['errorFlag'] ? 1 : 0).'</td>
+                                                               <td>'.htmlspecialchars($row['table_join']).'</td>
+                                                               <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
+                                                               <td>'.htmlspecialchars($row['query']).'</td>
+                                                       </tr>';
+                                       }
+                               } else {
+                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script, SUM(exec_time) as calc_sum, count(*) AS qrycount, MAX(errorFlag) as error','tx_dbal_debuglog','','tstamp,script','tstamp DESC');
+                                       $tRows = array();
+                                       $tRows[] = '
+                                               <tr>
+                                                       <td>Time</td>
+                                                       <td># of queries</td>
+                                                       <td>Error</td>
+                                                       <td>Time (ms)</td>
+                                                       <td>Script</td>
+                                               </tr>';
+                                       while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
+                                               $tRows[] = '
+                                                       <tr>
+                                                               <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
+                                                               <td>'.htmlspecialchars($row['qrycount']).'</td>
+                                                               <td>'.($row['error'] ? '<strong style="color:#f00">ERR</strong>' : '').'</td>
+                                                               <td>'.htmlspecialchars($row['calc_sum']).'</td>
+                                                               <td><a href="index.php?specTime='.intval($row['tstamp']).'">'.htmlspecialchars($row['script']).'</a></td>
+                                                       </tr>';
+                                       }
+                               }
+                               $outStr = '
+                                       <table border="1" cellspacing="0">'.implode('',$tRows).'
+                                       </table>';
+
+                       break;
+               }
+
+               $menu = '
+                                       <a href="index.php?cmd=flush">FLUSH LOG</a> -
+                                       <a href="index.php?cmd=joins">JOINS</a> -
+                                       <a href="index.php?cmd=errors">ERRORS</a> -
+                                       <a href="index.php?cmd=parsing">PARSING</a> -
+                                       <a href="index.php">LOG</a> -
+                                       <a href="index.php?cmd=where">WHERE</a> -
+
+                                       <a href="'.htmlspecialchars(t3lib_div::linkThisScript()).'" target="tx_debuglog">[New window]</a>
+                                       <hr />
+               ';
+               return $menu.$outStr;
+       }
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php'])        {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']);
+}
+
+
+
+
+// Make instance:
+$SOBE = t3lib_div::makeInstance('tx_dbal_module1');
+$SOBE->init();
+$SOBE->main();
+$SOBE->printContent();
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/mod1/locallang.xml b/typo3/sysext/dbal/mod1/locallang.xml
new file mode 100644 (file)
index 0000000..36212c1
--- /dev/null
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+    <meta type="array">
+        <description>DBAL debugging module</description>
+        <type>module</type>
+        <csh_table></csh_table>
+        <fileId>EXT:dbal/mod1/locallang.xml</fileId>
+        <labelContext type="array">
+            <label index="title"></label>
+            <label index="Debug_log"></label>
+            <label index="Cached_info"></label>
+            <label index="SQL_check"></label>
+        </labelContext>
+    </meta>
+    <data type="array">
+        <languageKey index="default" type="array">
+            <label index="title">DBAL Analysis Module</label>
+            <label index="Debug_log">Debug log</label>
+            <label index="Cached_info">Cached info</label>
+            <label index="SQL_check">SQL Check</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="title">DBAL Analyse-Module</label>
+            <label index="Debug_log">Debug-Log</label>
+            <label index="Cached_info">Info im Cache</label>
+            <label index="SQL_check">SQL-Test</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </data>
+    <orig_hash type="array">
+        <languageKey index="default" type="array">
+            <label index="title" type="integer">127017014</label>
+            <label index="Debug_log" type="integer">215559713</label>
+            <label index="Cached_info" type="integer">166779492</label>
+            <label index="SQL_check" type="integer">38048250</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="title" type="integer">127017014</label>
+            <label index="Debug_log" type="integer">215559713</label>
+            <label index="Cached_info" type="integer">166779492</label>
+            <label index="SQL_check" type="integer">38048250</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </orig_hash>
+    <orig_text type="array">
+        <languageKey index="default" type="array">
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </orig_text>
+</T3locallang>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/mod1/locallang_mod.xml b/typo3/sysext/dbal/mod1/locallang_mod.xml
new file mode 100644 (file)
index 0000000..86fa6e8
--- /dev/null
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+    <meta type="array">
+        <description>DBAL debugging module</description>
+        <type>module</type>
+        <csh_table></csh_table>
+        <fileId>EXT:dbal/mod1/locallang_mod.xml</fileId>
+        <labelContext type="array">
+            <label index="mlang_tabs_tab"></label>
+        </labelContext>
+    </meta>
+    <data type="array">
+        <languageKey index="default" type="array">
+            <label index="mlang_tabs_tab">DBAL Debug</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="mlang_tabs_tab">DBAL Debug</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </data>
+    <orig_hash type="array">
+        <languageKey index="default" type="array">
+            <label index="mlang_tabs_tab" type="integer">224432571</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="mlang_tabs_tab" type="integer">224432571</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </orig_hash>
+    <orig_text type="array">
+        <languageKey index="default" type="array">
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+    </orig_text>
+</T3locallang>
\ No newline at end of file
diff --git a/typo3/sysext/dbal/mod1/moduleicon.gif b/typo3/sysext/dbal/mod1/moduleicon.gif
new file mode 100644 (file)
index 0000000..3c43d27
Binary files /dev/null and b/typo3/sysext/dbal/mod1/moduleicon.gif differ