ultimix
database_1_0_0 Class Reference

Public Member Functions

 __construct ()
 get_object ()
 query ($Query)
 query_as ($theQueryMode)
 select ($What, $Tables, $Condition= '1=1')
 fetch_results ($Result)
 insert ($Table, $Fields, $Values)
 delete ($Table, $Condition= '1=1')
 update ($Table, $Fields, $Values, $Condition= '1=1')
 create ($Table, $FirstIndexField= 'id')
 drop ($Table)
 lock ($Tables, $Modes)
 unlock ()
 savepoint ($Savepoint)
 rollback ($Savepoint)
 transaction ()
 commit ()

Data Fields

 $CachedMultyFS = false
 $DatabaseLogger = false
 $PageComposer = false
 $Security = false
 $Settings = false
 $String = false
 $Text = false
 $Tags = false
 $DatabaseAccessObject = false
 $DatabaseEncoding = 'UTF-8'
 $QueryCounter = 0
 $DBLogging
 $TablenamePrefix

Static Public Attributes

static $Session = false

Detailed Description

Class providees routine for database manipulation.

Author
Dodonov A.A.

Definition at line 30 of file database.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 137 of file database.php.

{
try
{
$this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$this->DatabaseLogger = get_package( 'database::database_logger' , 'last' , __FILE__ );
$this->PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$this->String = get_package( 'string' , 'last' , __FILE__ );
$this->Text = get_package( 'string::text' , 'last' , __FILE__ );
$this->Tags = get_package( 'string::tags' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

commit ( )

Function commits transaction.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 840 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->commit();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
create (   $Table,
  $FirstIndexField = 'id' 
)

Executes delete query.

Parameters
$Table- Created table.
$FirstIndexField- Name of index field. Field will be created automatically.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 624 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->create( $Table , $FirstIndexField );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete (   $Table,
  $Condition = '1 = 1' 
)

Executes delete query.

Parameters
$Table- Record (or records) will be deleted from this table.
$Condition- Record selection condition.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 544 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->delete( $Table , $Condition );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
drop (   $Table)

Executes delete table query.

Parameters
$Table- Deleted table.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 656 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->drop( $Table );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
fetch_results (   $Result)

Function fetches results of the query.

Parameters
$Result- Query result object.
Returns
Array of selected records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 461 of file database.php.

{
try
{
$DBO = $this->get_object();
$Result = $DBO->fetch_results( $Result );
if( $this->DatabaseEncoding != 'UTF-8' )
{
$Result = $this->Text->iconv( $this->DatabaseEncoding , 'UTF-8' , $Result );
}
return( $Result );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_object ( )

Function executes query.

Returns
Data access object.
Exceptions
Exception- An exception of this type is thrown.
Author
Додонов А.А.

Definition at line 281 of file database.php.

{
try
{
if( $this->DatabaseAccessObject === false )
{
$Config = $this->CachedMultyFS->get_config( __FILE__ , 'cf_database_settings' );
$Config = explode( '#' , $Config );
$this->DatabaseAccessObject = get_package( $Config[ 0 ] , $Config[ 1 ] , __FILE__ );
$this->DatabaseAccessObject->get_connection();
$this->setup( $Config );
}
return( $this->DatabaseAccessObject );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
insert (   $Table,
  $Fields,
  $Values 
)

Executes insert query.

Parameters
$Table- New record will be inserted in this table.
$Fields- List of fields wich will be filled while record insertion.
$Values- Field values.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 508 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->insert( $Table , $Fields , $Values );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
lock (   $Tables,
  $Modes 
)

Function blocks tables.

Parameters
$Tables- Blocking tables.
$Modes- Blocking modes.
Exceptions
Exception- An exception of this type is thrown.
Author
Додонов А.А.

Definition at line 692 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->lock( $Tables , $Modes );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
query (   $Query)

Function executes query.

Parameters
$Query- Query string.
Returns
Query result.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 326 of file database.php.

{
try
{
$Start = microtime( true );
$this->QueryCounter++;
$DBO = $this->get_object();
$Query = str_replace( array( '[eq]' ) , array( '=' ) , $Query );
if( $this->DatabaseEncoding != 'UTF-8' )
{
$Result = $this->Text->iconv(
$this->DatabaseEncoding , 'UTF-8' , $DBO->query( $this->Tags->compile_ultimix_tags( $Query ) )
);
}
else
{
$Result = $DBO->query( $this->Tags->compile_ultimix_tags( $Query ) );
}
$this->DatabaseLogger->log_query( $Query , $Start , $this->DBLogging );
return( $Result );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
query_as (   $theQueryMode)

Mode of extracting data from table.

Parameters
$theQueryMode- Either DB_ASSOC_ARRAY or DB_OBJECT.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 374 of file database.php.

{
try
{
$DBO = $this->get_object();
$DBO->query_as( $theQueryMode );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
rollback (   $Savepoint)

Function rollbacks transaction to savepoint.

Parameters
$Savepoint- Savepoint.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 784 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->rollback( $Savepoint );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
savepoint (   $Savepoint)

Function sets savepoint.

Parameters
$Savepoint- Savepoint.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 752 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->savepoint( $Savepoint );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select (   $What,
  $Tables,
  $Condition = '1 = 1' 
)

Function executes select query.

Parameters
$What- List of selecting fields.
$Tables- List of tables to select data.
$Condition- Condition for records filtering.
Returns
Array of selected records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 417 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$Result = $DBO->select( $What , $Tables , $Condition );
if( $this->DatabaseEncoding != 'UTF-8' )
{
$Result = $this->Text->iconv( $this->DatabaseEncoding , 'UTF-8' , $Result );
}
return( $Result );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
transaction ( )

Function starts new transaction.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 812 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->transaction();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
unlock ( )

Function releases all locks for all tables.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 720 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->unlock();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $Table,
  $Fields,
  $Values,
  $Condition = '1 = 1' 
)

Executes update query.

Parameters
$Table- Record (or records) will be updated in this table.
$Fields- List of fields wich will be filled while record update.
$Values- Field values.
$Condition- Record selection condition.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 588 of file database.php.

{
try
{
$this->QueryCounter++;
$DBO = $this->get_object();
$DBO->update( $Table , $Fields , $Values , $Condition );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$CachedMultyFS = false

Cached objects.

Author
Dodonov A.A.

Definition at line 42 of file database.php.

$DatabaseAccessObject = false

DB access object.

Author
Dodonov A.A.

Definition at line 61 of file database.php.

$DatabaseEncoding = 'UTF-8'

Database default encoding.

Author
Dodonov A.A.

Definition at line 73 of file database.php.

$DatabaseLogger = false

Definition at line 43 of file database.php.

$DBLogging

Query logging.

Author
Dodonov A.A.

Definition at line 97 of file database.php.

$PageComposer = false

Definition at line 44 of file database.php.

$QueryCounter = 0

Counting database query.

Author
Dodonov A.A.

Definition at line 85 of file database.php.

$Security = false

Definition at line 45 of file database.php.

$Session = false
static

Session.

Author
Dodonov A.A.

Definition at line 121 of file database.php.

$Settings = false

Definition at line 46 of file database.php.

$String = false

Definition at line 47 of file database.php.

$TablenamePrefix

Table name's prefix.

Author
Dodonov A.A.

Definition at line 109 of file database.php.

$Tags = false

Definition at line 49 of file database.php.

$Text = false

Definition at line 48 of file database.php.


The documentation for this class was generated from the following file: