Class PdoDatabase

Description

Typically there will only be a single instance of the database level class in an application.

Located in /inc/PdoQuery.php (line 218)


	
			
Variable Summary
 mixed $querycount
 mixed $querytime
 mixed $txnstate
Method Summary
 PdoDatabase __construct (string $connection_string, [string $dbuser = null], [string $dbpass = null], [array $options = null])
 void Begin ()
 void Commit ()
 mixed Exec (string $sql_query_string, mixed 1)
 void GetFields ( $tablename_string)
 void Prepare (string $sql_query_string, mixed 1)
 void Rollback ()
 void TotalDuration ()
 void TotalQueries ()
 void TranslateAll ( $onoff_boolean)
Variables
mixed $querycount = 0 (line 241)

Holds the count of queries executed so far

  • access: protected
mixed $querytime = 0 (line 246)

Holds the total duration of queries executed so far

  • access: protected
mixed $txnstate = 0 (line 236)

Holds the state of the transaction 0 = not started, 1 = in progress, -1 = error pending rollback/commit

  • access: protected
Methods
Constructor __construct (line 262)

The connection string is in the standard PDO format. The database won't actually be connected until the first database query is run against it.

The database object will also initialise and hold an PdoDialect object which will be used to provide database specific SQL for some queries, as well as translation hooks for instances where it is necessary to modify the SQL in transit to support additional databases.

PdoDatabase __construct (string $connection_string, [string $dbuser = null], [string $dbpass = null], [array $options = null])
  • string $connection_string: The PDO connection string, in all it's glory
  • string $dbuser: The database username to connect as
  • string $dbpass: The database password to connect with
  • array $options: An array of driver options
Begin (line 303)

Begin a transaction.

void Begin ()
Commit (line 317)

Complete a transaction.

void Commit ()
Exec (line 287)

Construct and execute an SQL statement from the sql_string, replacing the parameters into it.

  • return: false on error or number of rows affected. Test failure with === false
mixed Exec (string $sql_query_string, mixed 1)
  • string $sql_query_string: The SQL string containing optional variable replacements
  • mixed 1: ... Subsequent arguments are positionally replaced into the $sql_query_string
GetFields (line 368)

Returns an associative array of field types, keyed by field name, for the requested named table. Internally this calls PdoDialect::GetFields to get the required SQL and then processes the query in the normal manner.

void GetFields ( $tablename_string)
  • $tablename_string
Prepare (line 273)

Returns a PdoQuery object created using this database, the supplied SQL string, and any parameters given.

void Prepare (string $sql_query_string, mixed 1)
  • string $sql_query_string: The SQL string containing optional variable replacements
  • mixed 1: ... Subsequent arguments are positionally replaced into the $sql_query_string
PrepareTranslated (line 376)

Operates identically to PdoDatabase::Prepare, except that PdoDialect::Translate() will be called on the query before any processing.

void PrepareTranslated ()
Rollback (line 328)

Cancel a transaction in progress.

void Rollback ()
TotalDuration (line 351)

Returns the total duration of quries executed so far by this object instance.

void TotalDuration ()
TotalQueries (line 359)

Returns the total number of quries executed by this object instance.

void TotalQueries ()
TransactionState (line 343)

Returns the current state of a transaction, indicating if we have begun a transaction, whether the transaction has failed, or if we are not in a transaction.

void TransactionState ()
TranslateAll (line 384)

Switches on or off the processing flag controlling whether subsequent calls to PdoDatabase::Prepare are translated as if PrepareTranslated() had been called.

void TranslateAll ( $onoff_boolean)
  • $onoff_boolean

Documentation generated on Fri, 10 Apr 2009 23:45:53 +1200 by phpDocumentor 1.3.2