Public Member Functions | Protected Member Functions | Protected Attributes

PGsqlEngine Class Reference

MySQL adaptation of DB-Engine. More...

Inheritance diagram for PGsqlEngine:
DbEngine

List of all members.

Public Member Functions

 __construct ($connstring)
 initialize driver
 __destruct ()
 make sure it shuts down
 beginTransaction ()
 begins a transaction; must be implemented by driver; use sqlBeginTransaction to create the SQL statement!
 commitTransaction ()
 ends a transaction successfully; must be implemented by driver; returns true on success; use sqlCommitTransaction to create the SQL statement!
 deleteRows ($table, $where)
 delete database values; returns the amount of rows deleted or false if an error occurred; use sqlDelete to create the SQL statement!
 escapeBlob ($s)
 escapes blobs; it uses mysqli_escape_string and encloses the value in '' - blobs are binary strings in MySQL
 escapeString ($s)
 escapes strings; it uses mysqli_escape_string and encloses the value in ''
 hasTable ($tnm)
 returns whether the table exists; must be implemented by driver
 insert ($table, array $values)
 insert values into a table; returns false on failure, the new primary key if a sequence was set, true otherwise; use sqlInsert to create the SQL statement!
 lastError ()
 returns the error string of the last operation
 rollbackTransaction ()
 ends a transaction with a rollback; must be implemented by driver; returns true on success; use sqlRollbackTransaction to create the SQL statement!
 select ($table, $cols, $where="", $orderby="")
 gets some data from the database; $table is the name of the table, $cols is the list of columns to return or "*" for all, $where is the where clause of the SQL-statement, $orderby may contain additional ORDER BY or GROUP BY clauses; returns array of rows, which are in *_fetch_array format; returns false on error; use sqlSelect to create the SQL statement!; make sure that NULL values are returned as PHP value null (most DB drivers already do this)
 setCharacterSet ($c)
 set the default charset for tables and connections
 setDebugMode ($b=true, $a=false)
 development helper: activate debug mode
 setPrefix ($pre)
 set a table-name prefix for the database
 sqlBeginTransaction ()
 returns the SQL92 statement for beginning a transaction; overwrite this to implement DB specific syntax
 sqlCommitTransaction ()
 returns the SQL92 statement for committing a transaction; overwrite this to implement DB specific syntax
 sqlRollbackTransaction ()
 returns the SQL92 statement for rolling a transaction back; overwrite this to implement DB specific syntax
 syncSequence ($table)
 synchronize the sequence of one database table
 tryConnect ()
 connect to the database, must be overwritten by DB driver
 update ($table, array $values, $where)
 update database values; returns how many rows have been changed or false for failure; use sqlUpdate to create the SQL statement!

Protected Member Functions

 columnFlag ($flag, $col, $table)
 returns the correct name/coding of a flag: primarykey, notnull, unique (implies notnull), foreignkey:$table:$col, defaultint:$val, defaultstr:$val, index
 createTable ($tn, $t)
 creates a table; the argument is an array of the form "col-name" => array("col-type", "flags"...); use sqlCreateTable() etc.
 dataType ($type)
 returns the correct type name for the required abstract data type; types that must be understood are: int32 (INTEGER), int64 (LONG INTEGER), seq32 (auto-incrementing int), seq64, bool (boolean), string:$length (text up to 255 chars, length is optional, default is 255; VARCHAR($length)), text (unlimited text)
 lockDB ($wl)
 locks the database - only used by the backup functions; if necessary should also start a transaction; default just starts a transaction
 sqlCreateTable ($tn, $t)
 creates a SQL92 statement for creating a table; overwrite this to implement DB specific syntax
 tableName ($tn)
 transform an internally used table name to the actual table name in the DB; the default implementation returns exactly what it gets
 unescapeBool ($b)
 internal: unescape a postgres bool towards PHP bool

Protected Attributes

 $prefix = ""
 prefix for table names

Detailed Description

MySQL adaptation of DB-Engine.


Constructor & Destructor Documentation

PGsqlEngine::__construct ( connstring  ) 

initialize driver

PGsqlEngine::__destruct (  ) 

make sure it shuts down

References rollbackTransaction().


Member Function Documentation

PGsqlEngine::beginTransaction (  ) 

begins a transaction; must be implemented by driver; use sqlBeginTransaction to create the SQL statement!

Reimplemented from DbEngine.

References sqlBeginTransaction().

Referenced by lockDB().

PGsqlEngine::columnFlag ( flag,
col,
table 
) [protected]

returns the correct name/coding of a flag: primarykey, notnull, unique (implies notnull), foreignkey:$table:$col, defaultint:$val, defaultstr:$val, index

Reimplemented from DbEngine.

PGsqlEngine::commitTransaction (  ) 

ends a transaction successfully; must be implemented by driver; returns true on success; use sqlCommitTransaction to create the SQL statement!

Reimplemented from DbEngine.

References sqlCommitTransaction().

PGsqlEngine::createTable ( tablename,
table 
) [protected]

creates a table; the argument is an array of the form "col-name" => array("col-type", "flags"...); use sqlCreateTable() etc.

to create the actual statement

Reimplemented from DbEngine.

References sqlCreateTable().

PGsqlEngine::dataType ( type  )  [protected]

returns the correct type name for the required abstract data type; types that must be understood are: int32 (INTEGER), int64 (LONG INTEGER), seq32 (auto-incrementing int), seq64, bool (boolean), string:$length (text up to 255 chars, length is optional, default is 255; VARCHAR($length)), text (unlimited text)

Reimplemented from DbEngine.

PGsqlEngine::deleteRows ( table,
where 
)

delete database values; returns the amount of rows deleted or false if an error occurred; use sqlDelete to create the SQL statement!

Reimplemented from DbEngine.

References DbEngine::sqlDelete().

PGsqlEngine::escapeBlob ( s  ) 

escapes blobs; it uses mysqli_escape_string and encloses the value in '' - blobs are binary strings in MySQL

Reimplemented from DbEngine.

PGsqlEngine::escapeString ( s  ) 

escapes strings; it uses mysqli_escape_string and encloses the value in ''

Reimplemented from DbEngine.

PGsqlEngine::hasTable ( tablename  ) 

returns whether the table exists; must be implemented by driver

Reimplemented from DbEngine.

References $dbScheme, and tableName().

PGsqlEngine::insert ( table,
array $  values 
)

insert values into a table; returns false on failure, the new primary key if a sequence was set, true otherwise; use sqlInsert to create the SQL statement!

Reimplemented from DbEngine.

References $dbScheme, and DbEngine::sqlInsert().

PGsqlEngine::lastError (  ) 

returns the error string of the last operation

Reimplemented from DbEngine.

PGsqlEngine::lockDB ( writelock  )  [protected]

locks the database - only used by the backup functions; if necessary should also start a transaction; default just starts a transaction

Reimplemented from DbEngine.

References $dbScheme, beginTransaction(), and tableName().

PGsqlEngine::rollbackTransaction (  ) 

ends a transaction with a rollback; must be implemented by driver; returns true on success; use sqlRollbackTransaction to create the SQL statement!

Reimplemented from DbEngine.

References sqlRollbackTransaction().

Referenced by __destruct().

PGsqlEngine::select ( table,
cols,
where = "",
orderby = "" 
)

gets some data from the database; $table is the name of the table, $cols is the list of columns to return or "*" for all, $where is the where clause of the SQL-statement, $orderby may contain additional ORDER BY or GROUP BY clauses; returns array of rows, which are in *_fetch_array format; returns false on error; use sqlSelect to create the SQL statement!; make sure that NULL values are returned as PHP value null (most DB drivers already do this)

Reimplemented from DbEngine.

References $dbScheme, DbEngine::sqlSelect(), and unescapeBool().

PGsqlEngine::setCharacterSet ( c  ) 

set the default charset for tables and connections

PGsqlEngine::setDebugMode ( b = true,
a = false 
)

development helper: activate debug mode

PGsqlEngine::setPrefix ( pre  ) 

set a table-name prefix for the database

PGsqlEngine::sqlBeginTransaction (  ) 

returns the SQL92 statement for beginning a transaction; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

Referenced by beginTransaction().

PGsqlEngine::sqlCommitTransaction (  ) 

returns the SQL92 statement for committing a transaction; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

Referenced by commitTransaction().

PGsqlEngine::sqlCreateTable ( tablename,
table 
) [protected]

creates a SQL92 statement for creating a table; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

References tableName().

Referenced by createTable().

PGsqlEngine::sqlRollbackTransaction (  ) 

returns the SQL92 statement for rolling a transaction back; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

Referenced by rollbackTransaction().

PGsqlEngine::syncSequence ( table  ) 

synchronize the sequence of one database table

Reimplemented from DbEngine.

References $dbScheme, and tableName().

PGsqlEngine::tableName ( tname  )  [protected]

transform an internally used table name to the actual table name in the DB; the default implementation returns exactly what it gets

Reimplemented from DbEngine.

Referenced by hasTable(), lockDB(), sqlCreateTable(), and syncSequence().

PGsqlEngine::tryConnect (  ) 

connect to the database, must be overwritten by DB driver

Reimplemented from DbEngine.

PGsqlEngine::unescapeBool ( b  )  [protected]

internal: unescape a postgres bool towards PHP bool

Referenced by select().

PGsqlEngine::update ( table,
array $  values,
where 
)

update database values; returns how many rows have been changed or false for failure; use sqlUpdate to create the SQL statement!

Reimplemented from DbEngine.

References DbEngine::sqlUpdate().


Member Data Documentation

PGsqlEngine::$prefix = "" [protected]

prefix for table names


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