Start a transaction against the RDBMS in order to wrap multiple
statements in a safe ACID-compliant container
static
void
begin_transaction
()
Updates the last error pointer to simulate resetting the error array
static
void
clear_errors
()
Commit a currently running transaction
static
void
commit
()
Connects to the database server. If no arguments are supplied, then the connection is attempted for the database authentication variables in config.php.
static
bool
connect
((optional) 0, (optional) 1, (optional) 2)
-
(optional)
0: connection_string a PDO connection string
-
(optional)
1: db_user the database user name
-
(optional)
2: db_pass the database user password
Automatic datbase diffing function, used for determining required database upgrades.
static
string
dbdelta
(queries $queries, [(optional) $execute = true], [(optional) $silent = true], [ $doinserts = false])
-
queries
$queries: array of create table and insert statements which constitute a fresh install
-
(optional)
$execute: execute should the queries be executed against the database or just simulated. default = true
-
(optional)
$silent: silent silent running with no messages printed? default = true
-
$doinserts
Deletes any record that matches the specific criteria
static
boolean
delete
(string $table, array $keyfields)
-
string
$table: Table to delete from
-
array
$keyfields: Associative array of field values to match
static
void
disconnect
()
static
void
exec
( $query)
Executes a stored procedure against the database
static
mixed
execute_procedure
(procedure $procedure, [args $args = array()])
-
procedure
$procedure: name of the stored procedure
-
args
$args: arguments for the procedure
Checks for a record that matches the specific criteria
static
boolean
exists
(string $table, array $keyfieldvalues)
-
string
$table: Table to check
-
array
$keyfieldvalues: Associative array of field values to match
Returns all values for a column for a query
static
array
get_column
(string $query, [array $args = array()])
-
string
$query: The query to execute
-
array
$args: Arguments to pass for prepared statements
static
void
get_driver_name
()
Returns error data gathered from database connection
static
array
get_errors
()
Returns an associative array using the first returned column as the array key and the second as the array value
static
array
get_keyvalue
(string $query, [array $args = array()])
-
string
$query: The query to execute
-
array
$args: Arguments to pass for prepared statements
Returns only the last error info
static
array
get_last_error
()
Returns query profiles
static
array
get_profiles
()
Execute a query and return the results as an array of objects
static
array
get_results
(query $query, [args $args = array()], string 2)
-
string
2: Optional class name for row result objects
-
query
$query: the query to execute
-
args
$args: array of arguments to pass for prepared statements
Returns a single row (the first in a multi-result set) object for a query
static
object A
get_row
(string $query, [array $args = array()], string 2)
-
string
2: Optional class name for row result object
-
string
$query: The query to execute
-
array
$args: Arguments to pass for prepared statements
Return a single value from the database
static
mixed
get_value
(string $query, [array $args = array()])
-
string
$query: the query to execute
-
array
$args: Arguments to pass for prepared statements
Determines if there have been errors since the last clear_errors() call
static
boolean
has_errors
()
Inserts into the specified table values associated to the key fields
static
boolean
insert
(string $table, array $fieldvalues)
-
string
$table: The table name
-
array
$fieldvalues: An associative array of fields and values to insert
Enables singleton working properly
static
void
instance
()
Redefinition of:
- Singleton::instance()
- Declarations that extend this method must have the same signature (arguments and returned types) to pass E_STRICT
Check whether there is a transaction underway.
static
boolean
in_transaction
()
Check whether there is an existing connection to a database.
static
boolean
is_connected
()
Helper function to return the last inserted sequence or auto_increment field. Useful when doing multiple inserts within a single transaction -- for example, adding dependent related rows.
static
mixed
last_insert_id
()
Returns a list of tables the DB currently knows about.
static
array
list_tables
()
Queries the database for a given SQL command.
static
bool
query
(query $query, [args $args = array()], class_name 2)
-
class_name
2: (optional) name of class name to wrangle returned data to
-
query
$query: the SQL query text
-
args
$args: array of values to use for placeholder replacement
Adds a table to the list of tables known to Habari. Used by Theme and Plugin classes to inform the DB class about custom tables used by the plugin
static
void
register_table
(name $name)
-
name
$name: the table name
Rolls a currently running transaction back to the prexisting state, or, if the RDBMS supports it, whenever a savepoint was committed.
static
void
rollback
()
Returns number of rows affected by the last DELETE, INSERT, or UPDATE
static
int
row_count
()
Sets the class to fetch, if fetch mode is PDO::FETCH_CLASS
static
void
set_fetch_class
(class_name $class_name)
-
class_name
$class_name: Name of class to create during fetch
Sets the fetch mode for return calls from PDOStatement
static
void
set_fetch_mode
(mode $mode)
-
mode
$mode: One of the PDO::FETCH_MODE integers
Helper function to naturally return table names
static
void
table
(table $name)
-
table
$name: name of the table
function update
Updates any record that matches the specific criteria A new row is inserted if no existing record matches the criteria
static
boolean
update
(string $table, array $fieldvalues, array $keyfields)
-
string
$table: Table to update
-
array
$fieldvalues: Associative array of field values to set
-
array
$keyfields: Associative array of field values to match
Upgrade data in the database between database revisions
static
void
upgrade
(integer $old_version)
-
integer
$old_version: Optional version to upgrade to
Inherited Methods
Inherited From Singleton
Singleton::__construct()
Singleton::getInstanceOf()
Singleton::instance()