Returns the appropriate type of Connection class for the connect string passed or null on failure
static
mixed
ConnectionFactory
(connection_string $connect_string)
-
connection_string
$connect_string: a PDO connection string
Start a transaction against the RDBMS in order to wrap multiple
statements in a safe ACID-compliant container
void
begin_transaction
()
Updates the last error pointer to simulate resetting the error array
void
clear_errors
()
Commit a currently running transaction
void
commit
()
Connect to a database server
boolean
connect
(string $connect_string, string $db_user, string $db_pass)
-
string
$connect_string: a PDO connection string
-
string
$db_user: the database user name
-
string
$db_pass: the database user password
Redefined in descendants as:
-
SQLiteConnection::connect()
: Connect to SQLite Overrides the DatabaseConnection to return false if the SQLite file doesn't exist.
-
MySQLConnection::connect()
: Extends default connection method. It will be useful in order to allow accents and other DB-centric global commands.
Automatic diffing function, used for determining required database upgrades.
Implemented in child classes.
void
dbdelta
( $queries, [ $execute = true], [ $silent = true])
-
$queries
-
$execute
-
$silent
Redefined in descendants as:
-
SQLiteConnection::dbdelta()
: automatic diffing function - used for determining required database upgrades based on Owen Winkler's microwiki upgrade function
-
MySQLConnection::dbdelta()
: automatic diffing function - used for determining required database upgrades based on Owen Winkler's microwiki upgrade function
-
PGSQLConnection::dbdelta()
: automatic diffing function - used for determining required database upgrades based on Owen Winkler's microwiki upgrade function
Deletes any record that matches the specific criteria
boolean
delete
(string $table, array $keyfields)
-
string
$table: Table to delete from
-
array
$keyfields: Associative array of field values to match
Disconnect from the database server.
boolean
disconnect
()
Execute the given query on the database. Encapsulates PDO::exec.
WARNING: Make sure you don't call this with a SELECT statement. PDO will buffer the results and leave your cursor dangling.
boolean
exec
(string $query)
-
string
$query: the query to run
Execute a stored procedure
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
boolean
exists
(string $table, array $keyfieldvalues)
-
string
$table: Table to check
-
array
$keyfieldvalues: Associative array of field values to match
Replace braced table names with their prefixed counterparts
string
filter_tables
(string $query)
-
string
$query: The query with {braced} table names
Returns all values for a column for a query
array
get_column
(string $query, [array $args = array()])
-
string
$query: The query to execute
-
array
$args: Arguments to pass for prepared statements
Returns error data gathered from database connection
array
get_errors
()
Returns an associative array using the first returned column as the array key and the second as the array value
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
array
get_last_error
()
Returns query profiles
array
get_profiles
()
Execute a query and return the results as an array of objects
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
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
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
boolean
has_errors
()
Inserts into the specified table values associated to the key fields
boolean
insert
(string $table, array $fieldvalues)
-
string
$table: The table name
-
array
$fieldvalues: An associative array of fields and values to insert
Check whether there is a transaction underway.
boolean
in_transaction
()
Check whether there is an existing connection to a database.
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.
mixed
last_insert_id
()
Returns a list of tables the DB currently knows about.
array
list_tables
()
Populate the table mapping.
void
load_tables
()
Execute a SQL statement.
boolean
query
(string $query, [array $args = array()])
-
string
$query: the SQL statement
-
array
$args: values for the bound parameters
Load a file containing queries, replace the prefix, execute all queries present
boolean
query_file
(string $file)
-
string
$file: The filename containing the queries
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
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.
void
rollback
()
Returns number of rows affected by the last DELETE, INSERT, or UPDATE
int
row_count
()
Sets the class to fetch, if fetch mode is PDO::FETCH_CLASS
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
void
set_fetch_mode
(mode $mode)
-
mode
$mode: One of the PDO::FETCH_MODE integers
Translates the query for the current database engine
string
sql_t
(string $query, array $args)
-
string
$query: The query to translate for the current database engine
-
array
$args: Arguments to the query
Redefined in descendants as:
Get the full table name for the given table.
string
table
(string $name)
-
string
$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
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
Updates the content of the database between versions.
Implemented in child classes.
void
upgrade
(integer $old_version, [ $upgrade_path = ''])
-
integer
$old_version: The old Version::DB_VERSION
-
$upgrade_path
Redefined in descendants as: