16 define(
'DB_ASSOC_ARRAY' , 1 );
17 define(
'DB_OBJECT' , 2 );
18 define(
'DB_ARRAY' , 3 );
141 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
142 $this->DatabaseLogger =
get_package(
'database::database_logger' ,
'last' , __FILE__ );
143 $this->PageComposer =
get_package(
'page::page_composer' ,
'last' , __FILE__ );
144 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
146 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
147 $this->Text =
get_package(
'string::text' ,
'last' , __FILE__ );
148 $this->Tags =
get_package(
'string::tags' ,
'last' , __FILE__ );
150 catch( Exception $e )
174 private function compile_config_line( $ConfigLine )
178 $this->Settings->load_settings( $ConfigLine );
179 $PackageName = $this->Settings->get_setting(
'package_name' );
180 $PackageVersion = $this->Settings->get_setting(
'package_version' ,
'last' );
181 $AddLimitations = $this->Settings->get_setting(
'data_limitation' );
182 $Package =
get_package( $PackageName , $PackageVersion , __FILE__ );
183 $Package->set_add_limitations( $AddLimitations );
185 catch( Exception $e )
205 private function apply_add_limitations()
209 $Config = $this->CachedMultyFS->get_config( __FILE__ ,
'cf_add_limitations' ,
'cleaned' );
213 $Config = explode(
"\n" , $Config );
215 foreach( $Config as $k => $ConfigLine )
217 $this->compile_config_line( $ConfigLine );
221 catch( Exception $e )
245 private function setup( &$Config )
249 $this->DatabaseEncoding = $Config[ 2 ];
250 $this->DBLogging = intval( @$Config[ 3 ] ) === 1 ?
true :
false;
251 $this->TablenamePrefix = $this->DatabaseAccessObject->TablenamePrefix;
252 self::$Session = microtime(
true );
253 $this->DatabaseAccessObject->query(
'SET AUTOCOMMIT = 0' );
254 $this->DatabaseAccessObject->query(
'SET NAMES utf8' );
255 $this->apply_add_limitations();
257 catch( Exception $e )
285 if( $this->DatabaseAccessObject ===
false )
287 $Config = $this->CachedMultyFS->get_config( __FILE__ ,
'cf_database_settings' );
288 $Config = explode(
'#' , $Config );
289 $this->DatabaseAccessObject =
get_package( $Config[ 0 ] , $Config[ 1 ] , __FILE__ );
291 $this->DatabaseAccessObject->get_connection();
293 $this->setup( $Config );
296 return( $this->DatabaseAccessObject );
298 catch( Exception $e )
330 $Start = microtime(
true );
331 $this->QueryCounter++;
333 $Query = str_replace( array(
'[eq]' ) , array(
'=' ) , $Query );
335 if( $this->DatabaseEncoding !=
'UTF-8' )
337 $Result = $this->Text->iconv(
338 $this->DatabaseEncoding ,
'UTF-8' , $DBO->query( $this->Tags->compile_ultimix_tags( $Query ) )
343 $Result = $DBO->query( $this->Tags->compile_ultimix_tags( $Query ) );
346 $this->DatabaseLogger->log_query( $Query , $Start , $this->DBLogging );
350 catch( Exception $e )
379 $DBO->query_as( $theQueryMode );
381 catch( Exception $e )
417 function select( $What , $Tables , $Condition =
'1 = 1' )
421 $this->QueryCounter++;
424 $Result = $DBO->select( $What , $Tables , $Condition );
426 if( $this->DatabaseEncoding !=
'UTF-8' )
428 $Result = $this->Text->iconv( $this->DatabaseEncoding ,
'UTF-8' , $Result );
433 catch( Exception $e )
467 $Result = $DBO->fetch_results( $Result );
469 if( $this->DatabaseEncoding !=
'UTF-8' )
471 $Result = $this->Text->iconv( $this->DatabaseEncoding ,
'UTF-8' , $Result );
476 catch( Exception $e )
508 function insert( $Table , $Fields , $Values )
512 $this->QueryCounter++;
514 $DBO->insert( $Table , $Fields , $Values );
516 catch( Exception $e )
544 function delete( $Table , $Condition =
'1 = 1' )
548 $this->QueryCounter++;
550 $DBO->delete( $Table , $Condition );
552 catch( Exception $e )
588 function update( $Table , $Fields , $Values , $Condition =
'1 = 1' )
592 $this->QueryCounter++;
594 $DBO->update( $Table , $Fields , $Values , $Condition );
596 catch( Exception $e )
624 function create( $Table , $FirstIndexField =
'id' )
628 $this->QueryCounter++;
630 $DBO->create( $Table , $FirstIndexField );
632 catch( Exception $e )
660 $this->QueryCounter++;
662 $DBO->drop( $Table );
664 catch( Exception $e )
692 function lock( $Tables , $Modes )
696 $this->QueryCounter++;
698 $DBO->lock( $Tables , $Modes );
700 catch( Exception $e )
724 $this->QueryCounter++;
728 catch( Exception $e )
756 $this->QueryCounter++;
758 $DBO->savepoint( $Savepoint );
760 catch( Exception $e )
788 $this->QueryCounter++;
790 $DBO->rollback( $Savepoint );
792 catch( Exception $e )
816 $this->QueryCounter++;
820 catch( Exception $e )
844 $this->QueryCounter++;
848 catch( Exception $e )