Documentation TYPO3 par Ameos

class.tx_dbal_handler_rawmysql.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00086 class tx_dbal_handler_rawmysql extends t3lib_sqlengine {
00087 
00088         var $config = array();  
00089         var $link;
00090         var $pObj;      // Set from DBAL class.
00091 
00100         function init($config,&$pObj)   {
00101                 $this->config = $config['config'];
00102                 $this->pObj = &$pObj;
00103                 $this->link = mysql_pconnect(
00104                                                         $this->config['host'], 
00105                                                         $this->config['username'], 
00106                                                         $this->config['password']
00107                                                 );
00108 
00109                         // Select database as well:
00110                 if (mysql_select_db($this->config['database'], $this->link))    {
00111                         $output = TRUE;
00112                 }
00113 
00114                 return $output;
00115         }
00116 
00124         function exec_INSERTquery($table,$fields_values)        {
00125                 return mysql_query($GLOBALS['TYPO3_DB']->INSERTquery($table,$fields_values), $this->link);
00126         }
00127 
00136         function exec_UPDATEquery($table,$where,$fields_values) {
00137                 return mysql_query($GLOBALS['TYPO3_DB']->UPDATEquery($table,$where,$fields_values), $this->link);
00138         }
00139 
00147         function exec_DELETEquery($table,$where)        {
00148                 return mysql_query($GLOBALS['TYPO3_DB']->DELETEquery($table,$where), $this->link);
00149         }
00150 
00162         function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)    {
00163                 $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');              // Create result object
00164                 $this->pObj->lastQuery = $GLOBALS['TYPO3_DB']->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
00165                 $res->result = mysql(TYPO3_db, $this->pObj->lastQuery, $this->link);    // Execute query
00166                 return $res;
00167         }
00168 
00174         function sql_error()    {
00175                 return mysql_error();
00176         }
00177 
00183         function sql_insert_id()        {
00184                 return mysql_insert_id();
00185         }
00186 
00192         function sql_affected_rows()    {
00193                 return mysql_affected_rows();
00194         }
00195 
00202         function sql_query($query)      {
00203                 $res = t3lib_div::makeInstance('tx_dbal_handler_rawmysql_sqlObj');
00204                 $res->result = mysql_query($query, $this->link);
00205                 return $res;
00206         }
00207 
00214         function quoteStr($str) {
00215                 return addslashes($str);
00216         }
00217         
00218         
00219         
00220 
00221 
00222 
00223 
00224 
00225 
00226         /**************************************
00227          *
00228          * SQL admin functions
00229          * (For use in the Install Tool and Extension Manager)
00230          *
00231          **************************************/
00232 
00238         function admin_get_tables()     {
00239                 $whichTables = array();
00240                 $tables_result = mysql_list_tables($this->config['database'], $this->link);
00241                 if (!mysql_error())     {
00242                         while ($theTable = mysql_fetch_assoc($tables_result)) {
00243                                 $whichTables[current($theTable)] = current($theTable);
00244                         }
00245                 }
00246                 return $whichTables;
00247         }
00248 
00255         function admin_get_fields($tableName)   {
00256                 $output = array();
00257                 
00258                 if ($columns_res = @mysql_query('SHOW columns FROM '.$tableName, $this->link))  {
00259                         while($fieldRow = mysql_fetch_assoc($columns_res))      {
00260                                 $output[$fieldRow["Field"]] = $fieldRow;
00261                         }
00262                 }
00263 
00264                 return $output;
00265         }
00266 
00273         function admin_get_keys($tableName)     {
00274                 $output = array();
00275 
00276                 if ($keyRes = @mysql_query('SHOW keys FROM '.$tableName, $this->link))  {
00277                         while($keyRow = mysql_fetch_assoc($keyRes))     {
00278                                 $output[] = $keyRow;
00279                         }
00280                 }
00281 
00282                 return $output;
00283         }               
00284 
00291         function admin_query($query)    {
00292                 return $this->sql_query($query);
00293         }       
00294 }
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00309 class tx_dbal_handler_rawmysql_sqlObj extends t3lib_sqlengine_resultobj {
00310 
00311         var $result = '';                       // Not array here, but resource pointer.
00312 
00318         function sql_num_rows() {
00319                 return mysql_num_rows($this->result);
00320         }
00321 
00327         function sql_fetch_assoc()      {
00328                 return mysql_fetch_assoc($this->result);
00329         }
00330 
00336         function sql_fetch_row()        {
00337                 return mysql_fetch_row($this->result);
00338         }
00339 
00346         function sql_data_seek($pointer)        {
00347                 return mysql_data_seek($this->result,$pointer);
00348         }
00349 }
00350 
00351 
00352 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php'])    {
00353         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_rawmysql.php']);
00354 }
00355 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6