ezdbinterface.php

00001 <?php
00002 //
00003 // $Id$
00004 //
00005 // Definition of eZDBInterface class
00006 //
00007 // Created on: <12-Feb-2002 15:54:17 bf>
00008 //
00009 // This source file is part of Exponential, publishing software.
00010 //
00011 // Copyright (C) 1999-2003 eZ Systems.  All rights reserved.
00012 //
00013 // This program is free software; you can redistribute it and/or
00014 // modify it under the terms of the GNU General Public License
00015 // as published by the Free Software Foundation; either version 2
00016 // of the License, or (at your option) any later version.
00017 //
00018 // This program is distributed in the hope that it will be useful,
00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 // GNU General Public License for more details.
00022 //
00023 // You should have received a copy of the GNU General Public License
00024 // along with this program; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
00026 //
00027 
00036 include_once( "lib/ezutils/classes/ezdebug.php" );
00037 include_once( "lib/ezutils/classes/ezini.php" );
00038 
00039 define( 'EZ_DB_RELATION_TABLE', 0 );
00040 define( 'EZ_DB_RELATION_SEQUENCE', 1 );
00041 define( 'EZ_DB_RELATION_TRIGGER', 2 );
00042 define( 'EZ_DB_RELATION_VIEW', 3 );
00043 define( 'EZ_DB_RELATION_INDEX', 4 );
00044 
00045 define( 'EZ_DB_RELATION_TABLE_BIT', (1 << EZ_DB_RELATION_TABLE) );
00046 define( 'EZ_DB_RELATION_SEQUENCE_BIT', (1 << EZ_DB_RELATION_SEQUENCE) );
00047 define( 'EZ_DB_RELATION_TRIGGER_BIT', (1 << EZ_DB_RELATION_TRIGGER) );
00048 define( 'EZ_DB_RELATION_VIEW_BIT', (1 << EZ_DB_RELATION_VIEW) );
00049 define( 'EZ_DB_RELATION_INDEX_BIT', (1 << EZ_DB_RELATION_INDEX) );
00050 
00051 define( 'EZ_DB_RELATION_NONE', 0 );
00052 define( 'EZ_DB_RELATION_MASK', ( EZ_DB_RELATION_TABLE_BIT |
00053                                  EZ_DB_RELATION_SEQUENCE_BIT |
00054                                  EZ_DB_RELATION_TRIGGER_BIT |
00055                                  EZ_DB_RELATION_VIEW_BIT |
00056                                  EZ_DB_RELATION_INDEX_BIT ) );
00057 
00058 define( 'EZ_DB_ERROR_MISSING_EXTENSION', 1 );
00059 
eZDBInterface
00061 {
eZDBInterface( $parameters )
00066     {
00067         $server = $parameters['server'];
00068         $user = $parameters['user'];
00069         $password = $parameters['password'];
00070         $db = $parameters['database'];
00071         $useSlaveServer = $parameters['use_slave_server'];
00072         $slaveServer = $parameters['slave_server'];
00073         $slaveUser = $parameters['slave_user'];
00074         $slavePassword = $parameters['slave_password'];
00075         $slaveDB =  $parameters['slave_database'];
00076         $socketPath = $parameters['socket'];
00077         $charset'];
00078         $builtinEncoding = $parameters['builtin_encoding'];
00079         $connectRetries = $parameters['connect_retries'];
00080 
00081         if ( $parameters['use_persistent_connection'] == 'enabled' )
00082         {
00083             $this->UsePersistentConnection = true;
00084         }
00085 
00086         $this->DB = $db;
00087         $this->Server = $server;
00088         $this->socketPath;
00089         $this->User = $user;
00090         $this->Password = $password;
00091         $this->UseSlaveServer = $useSlaveServer;
00092         $this->SlaveDB = $slaveDB;
00093         $this->SlaveServer = $slaveServer;
00094         $this->SlaveUser = $slaveUser;
00095         $this->SlavePassword = $slavePassword;
00096         $this->charset;
00097         $this->UseBuiltinEncoding = $builtinEncoding;
00098         $this->ConnectRetries = $connectRetries;
00099         $this->DBConnection = false;
00100         $this->DBWriteConnection = false;
00101 
00102         if ( $this->UseBuiltinEncoding )
00103         {
00104             include_once( "lib/ezi18n/classes/eztextcodec.php" );
00105             $this->charset );
00106             $this->InputTextCodec =& eZTextCodec::instance( charset );
00107         }
00108 
00109         $ini =& eZINI::instance();
00110         $this->OutputSQL = $ini->variable( "DatabaseSettings", "SQLOutput" ) == "enabled";
00111 
00112         $this->IsConnected = false;
00113         $this->NumQueries = 0;
00114         $this->StartTime = false;
00115         $this->EndTime = false;
00116         $this->TimeTaken = false;
00117     }
00118 
timeTaken )
00124     {
00125         $rowText = '';
00126         if ( $numRows !== false )
00127             $rowText = "$numRows rows, ";
00128         timeTaken, 3 ) . " ms) query number per page:" . $this->NumQueries++ );
00129     }
00130 
setIsSQLOutputEnabled( $enabled )
00135     {
00136         $this->OutputSQL = $enabled;
00137     }
00138 
startTimer()
00145     {
00146         $this->StartTime = microtime();
00147     }
00148 
endTimer()
00155     {
00156         $this->EndTime = microtime();
00157         // Calculate time taken in ms
00158         list($usec, $sec) = explode( " ", $this->StartTime );
00159         $start_val = ((float)$usec + (float)$sec);
00160         list($usec, $sec) = explode( " ", $this->EndTime );
00161         $end_val = ((float)$usec + (float)$sec);
00162         $this->TimeTaken = $end_val - $start_val;
00163         $this->TimeTaken *= 1000.0;
00164     }
00165 
startTime()
00171     {
00172         return $this->StartTime;
00173     }
00174 
endTime()
00180     {
00181         return $this->EndTime;
00182     }
00183 
timeTaken()
00189     {
00190         return $this->TimeTaken;
00191     }
00192 
databaseName()
00199     {
00200         return '';
00201     }
00202 
socketPath()
00207     {
00208         return $this->SocketPath;
00209     }
00210 
connectRetryCount()
00215     {
00216         return $this->ConnectRetries;
00217     }
00218 
connectRetryWaitTime()
00224     {
00225         return 3;
00226     }
00227 
supportedRelationTypeMask()
00233     {
00234         return EZ_DB_RELATION_NONE;
00235     }
00236 
supportedRelationTypes()
00242     {
00243         return array();
00244     }
00245 
00249     function databaseServerVersion()
00250     {
00251     }
00252 
00256     function databaseClientVersion()
00257     {
00258     }
00259 
charset()
00265     {
00266         return $this->Charset;
00267     }
00268 
usesBuiltinEncoding()
00275     {
00276         return $this->UseBuiltinEncoding;
00277     }
00278 
query( $sql )
00285     {
00286     }
00287 
arrayQuery( $sql, $params = array() )
00293     {
00294     }
00295 
lock( $table )
00301     {
00302     }
00303 
unlock()
00309     {
00310     }
00311 
begin()
00317     {
00318     }
00319 
commit()
00325     {
00326     }
00327 
rollback()
00333     {
00334     }
00335 
relationCounts( $relationMask )
00341     {
00342     }
00343 
relationCount( $relationType = EZ_DB_RELATION_TABLE )
00349     {
00350     }
00351 
relationList( $relationType = EZ_DB_RELATION_TABLE )
00357     {
00358     }
00359 
relationName, $relationType )
00366     {
00367         return false;
00368     }
00369 
relationName( $relationType )
00376     {
00377         $names = array( EZ_DB_RELATION_TABLE => 'TABLE',
00378                         EZ_DB_RELATION_SEQUENCE => 'SEQUENCE',
00379                         EZ_DB_RELATION_TRIGGER => 'TRIGGER',
00380                         EZ_DB_RELATION_VIEW => 'VIEW',
00381                         EZ_DB_RELATION_INDEX => 'INDEX' );
00382         if ( !isset( $names[$relationType] ) )
00383             return false;
00384         return $names[$relationType];
00385     }
00386 
lastSerialID( $table, $column )
00392     {
00393     }
00394 
escapeString( $str )
00400     {
00401     }
00402 
close()
00408     {
00409     }
00410 
isConnected()
00415     {
00416         return $this->IsConnected;
00417     }
00418 
createDatabase()
00424     {
00425     }
00426 
setError()
00432     {
00433     }
00434 
errorMessage()
00439     {
00440         return $this->ErrorMessage;
00441     }
00442 
errorNumber()
00447     {
00448         return $this->ErrorNumber;
00449     }
00450 
Server;
SocketPath;
DB;
DBConnection;
DBWriteConnection;
User;
Password;
Charset;
ConnectRetries;
OutputTextCodec;
UseBuiltinEncoding;
OutputSQL;
IsConnected = false;
NumQueries = 0;
StartTime;
EndTime;
TimeTaken;
ErrorMessage;
ErrorNumber;
RecordError = true;
UsePersistentConnection = false;
UserSlaveServer;
SlaveDB;
SlaveServer;
SlaveUser;
SlavePassword;
00504 }
00505 
00506 ?>
 

Exponential