Public Member Functions |
| | connect ($ConfigRow) |
| | get_connection ($ForceReconnect=false) |
| | 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) |
| | add_column ($Table, $ColumnName, $Type, $Mode= 'NOT NULL AFTER`id`') |
| | drop_column ($Table, $ColumnName) |
| | lock ($Tables, $Modes) |
| | unlock () |
| | savepoint ($Savepoint) |
| | rollback ($Savepoint) |
| | transaction () |
| | commit () |
Detailed Description
Class providees routine for database manipulation.
- Author
- Dodonov A.A.
Definition at line 26 of file postgre_database.php.
Member Function Documentation
| add_column |
( |
|
$Table, |
|
|
|
$ColumnName, |
|
|
|
$Type, |
|
|
|
$Mode = 'NOT NULL AFTER `id`' |
|
) |
| |
Function inserts column in table.
- Parameters
-
| $Table | - таблица, в которую добавляется столбец. |
| $ColumnName | - имя столбца. |
| $Type | - Тип столбца. |
| $Mode | - Режим добавления столбца. |
- Exceptions
-
| Exception | - кидается исключение этого типа с описанием ошибки. |
- Author
- Додонов А.А.
Definition at line 587 of file postgre_database.php.
{
try
{
$this->
query(
"ALTER TABLE `$Table` ADD COLUMN `$ColumnName` $Type $Mode" );
}
catch( Exception $e )
{
}
}
Function commits transaction.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 793 of file postgre_database.php.
{
try
{
$this->
query(
'COMMIT' );
}
catch( Exception $e )
{
}
}
Function connects to database.
- Parameters
-
| $ConfigRow | - String from the config. |
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 125 of file postgre_database.php.
{
try
{
$Config = explode(
"#" , $ConfigRow );
$this->TablenamePrefix =
$Config[ 4 ];
$this->Connection = @pg_pconnect(
'host='.$this->Host.' user='.$this->Username.' password='.$this->Password.' dbname='.$this->Database
);
}
catch( Exception $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 512 of file postgre_database.php.
{
try
{
"CREATE TABLE `$Table` ( `$FirstIndexField` INTEGER UNSIGNED NOT NULL DEFAULT NULL ".
"AUTO_INCREMENT , PRIMARY KEY ( `$FirstIndexField` ) )"
);
}
catch( Exception $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 428 of file postgre_database.php.
{
try
{
$this->
query(
"DELETE FROM $Table WHERE $Condition" );
}
catch( Exception $e )
{
}
}
Executes delete table query.
- Parameters
-
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 545 of file postgre_database.php.
{
try
{
$this->
query(
"DROP TABLE $Table" );
}
catch( Exception $e )
{
}
}
| drop_column |
( |
|
$Table, |
|
|
|
$ColumnName |
|
) |
| |
Function deletes column from table.
- Parameters
-
| $Table | - Name of the editig table (column will be deleted). |
| $ColumnName | - Name of the deleting column. |
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 621 of file postgre_database.php.
{
try
{
$this->
query(
"ALTER TABLE `$Table` DROP COLUMN `$ColumnName`" );
}
catch( Exception $e )
{
}
}
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 340 of file postgre_database.php.
{
try
{
$RetValues = array();
for( $i = 0; $i < $Result->num_rows ; $i++ )
{
{
$RetValues [] = $Result->fetch_array( MYSQLI_ASSOC );
}
{
$RetValues [] = $Result->fetch_object();
}
}
$Result->close();
return( $RetValues );
}
catch( Exception $e )
{
}
}
| get_connection |
( |
|
$ForceReconnect = false | ) |
|
Function returns database connection.
- Parameters
-
| $ForceReconnect | - Force reconnect to database. |
- Returns
- mysqli object.
- Author
- Dodonov A.A.
Definition at line 164 of file postgre_database.php.
{
try
{
if( $this->Connection === false || $ForceReconnect ===true )
{
if( $this->Connection !== false )
{
pg_close( $this->Connection );
}
$DBConfigSet =
get_package(
'database::db_config_set' ,
'last' , __FILE__ );
$DBConfigSet->load_config( dirname( __FILE__ ).'/conf/cf_postgre_database' );
$this->Connection = $DBConfigSet->connect( $this );
if( pg_last_error() !== false )
{
throw(
new Exception(
'An error occured while setting connection to the database '.pg_last_error()
)
);
}
}
return( $this->Connection );
}
catch( Exception $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 394 of file postgre_database.php.
{
try
{
$this->
query(
"INSERT INTO $Table ( $Fields ) VALUES ( $Values )" );
}
catch( Exception $e )
{
}
}
Function blocks tables.
- Parameters
-
| $Tables | - Tables to block. |
| $Modes | - Blocking modes. |
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 655 of file postgre_database.php.
{
try
{
throw( new Exception( "Table locking unavailable" ) );
}
catch( Exception $e )
{
}
}
Function executes query.
- Parameters
-
- Returns
- Query result.
- Author
- Dodonov A.A.
Definition at line 212 of file postgre_database.php.
{
try
{
$Start = microtime( true );
$Query = str_replace( 'umx_' , $this->TablenamePrefix , $Query );
{
throw(
new Exception(
'An error occured while query execution '.
$Connection->error ) );
}
$End = microtime( true );
if( $this->DBLogging )
{
'umx_actions' ,
'action_name , time , info' , "'".self::$QueryName."' , ".( $End - $Start )." , '".
htmlspecialchars( $Query , ENT_QUOTES )."'"
);
}
return( $Result );
}
catch( Exception $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 262 of file postgre_database.php.
{
try
{
self::$QueryMode = $theQueryMode;
}
catch( Exception $e )
{
}
}
Function rollbacks transaction to savepoint.
- Parameters
-
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 741 of file postgre_database.php.
{
try
{
$this->
query(
'ROLLBACK TO SAVEPOINT '.$Savepoint );
}
catch( Exception $e )
{
}
}
Function sets savepoint.
- Parameters
-
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 711 of file postgre_database.php.
{
try
{
$this->
query(
'SAVEPOINT '.$Savepoint );
}
catch( Exception $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 304 of file postgre_database.php.
{
try
{
$Result = $this->
query(
"SELECT $What FROM $Tables WHERE $Condition" );
}
catch( Exception $e )
{
}
}
Function starts new transaction.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 767 of file postgre_database.php.
{
try
{
$this->
query(
'START TRANSACTION' );
}
catch( Exception $e )
{
}
}
Function releases all locks for all tables.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 681 of file postgre_database.php.
{
try
{
throw( new Exception( "Table locking unavailable" ) );
}
catch( Exception $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 470 of file postgre_database.php.
{
try
{
$SubQuery = '';
for( $i = 0 ; $i < count( $Fields ) - 1 ; $i++ )
{
$SubQuery .= $Fields[ $i ].' = '.$Values[ $i ].' , ';
}
$SubQuery .= $Fields[ count( $Fields ) - 1 ].' = '.$Values[ count( $Fields ) - 1 ];
$this->
query(
"UPDATE $Table SET $SubQuery WHERE $Condition" );
}
catch( Exception $e )
{
}
}
Field Documentation
Data querying mode. Either DB_ASSOC_ARRAY (record is reprecented as associative array) or DB_OBJECT (record is represented as an object).
- Author
- Dodonov A.A.
Definition at line 76 of file postgre_database.php.
The documentation for this class was generated from the following file: