$_config
$_config : array
Config options.
MySQL Improved Horde_Db_Adapter
$_schema : \Horde_Db_Adapter_Base_Schema
Schema object.
prefetchPrimaryKey( $tableName = null) : boolean
Should primary key values be selected from their corresponding sequence before the insert statement? If true, next_sequence_value is called before each insert to set the record's primary key.
This is false for all adapters but Firebird.
$tableName |
None found |
None found |
cacheWrite(string $key, string $value)
Writes values to the cache handler.
The key is automatically prefixed to avoid collisions when using different adapters or different configurations.
string | $key | A cache key. |
string | $value | A value. |
since |
Horde_Db 2.1.0 |
---|
cacheRead(string $key) : string
Reads values from the cache handler.
The key is automatically prefixed to avoid collisions when using different adapters or different configurations.
string | $key | A cache key. |
A value.
since |
Horde_Db 2.1.0 |
---|
None found |
rawConnection() : resource
Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.
None found |
selectAll(string $sql, mixed $arg1 = null, string $arg2 = null) : array
Returns an array of record hashes with the column names as keys and column values as values.
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
selectOne(string $sql, mixed $arg1 = null, string $arg2 = null) : array|boolean
Returns a record hash with the column names as keys and column values as values.
string | $sql | A query. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
A record hash or false if no record found.
None found |
selectValue(string $sql, mixed $arg1 = null, string $arg2 = null) : string
Returns a single value from a record
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
selectValues(string $sql, mixed $arg1 = null, string $arg2 = null) : array
Returns an array of the values of the first column in a select: select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
selectAssoc(string $sql, mixed $arg1 = null, string $arg2 = null) : array
Returns an array where the keys are the first column of a select, and the values are the second column:
selectAssoc("SELECT id, name FROM companies LIMIT 3") => [1 => 'Ford', 2 => 'GM', 3 => 'Chrysler']
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
insertBlob(string $table, array $fields, string $pk = null, mixed $idValue = null) : integer
Inserts a row including BLOBs into a table.
string | $table | The table name. |
array | $fields | A hash of column names and values. BLOB/CLOB columns must be provided as Horde_Db_Value objects. |
string | $pk | The primary key column. |
mixed | $idValue | The primary key value. This parameter is required if the primary key is inserted manually. |
Last inserted ID.
since |
Horde_Db 2.1.0 |
---|
update(string $sql, mixed $arg1 = null, string $arg2 = null) : integer
Executes the update statement and returns the number of rows affected.
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
Number of rows affected.
None found |
updateBlob(string $table, array $fields, string|array $where = null)
Updates rows including BLOBs into a table.
string | $table | The table name. |
array | $fields | A hash of column names and values. BLOB/CLOB columns must be provided as Horde_Db_Value objects. |
string|array | $where | A WHERE clause. Either a complete clause or an array containing a clause with placeholders and a list of values. |
since |
Horde_Db 2.2.0 |
---|
delete(string $sql, mixed $arg1 = null, string $arg2 = null) : integer
Executes the delete statement and returns the number of rows affected.
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
Number of rows affected.
None found |
transactionStarted() : boolean
Check if a transaction has been started.
True if transaction has been started.
None found |
addLimitOffset(string $sql, array $options) : string
Appends LIMIT and OFFSET options to a SQL statement.
string | $sql | SQL statement. |
array | $options | Hash with 'limit' and (optional) 'offset' values. |
None found |
None found |
addLock( $sql, array $options = array())
Appends a locking clause to an SQL statement.
This method modifies the +sql+ parameter.
add_lock! 'SELECT FROM suppliers', :lock => true add_lock! 'SELECT FROM suppliers', :lock => ' FOR UPDATE'
$sql | ||
array | $options | TODO. |
None found |
insertFixture(\TODO $fixture, \TODO $tableName) : \TODO
Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).
\TODO | $fixture | TODO |
\TODO | $tableName | TODO |
None found |
emptyInsertStatement(string $tableName) : string
TODO
string | $tableName | TODO |
TODO
None found |
connect()
Connect to the db
MySQLi can connect using SSL if $config contains an 'ssl' sub-array containing the following keys:
Example of how to connect using SSL:
$config = array(
'username' => 'someuser',
'password' => 'apasswd',
'hostspec' => 'localhost',
'database' => 'thedb',
'ssl' => array(
'key' => 'client-key.pem',
'cert' => 'client-cert.pem',
'ca' => 'cacert.pem',
'capath' => '/path/to/ca/dir',
'cipher' => 'AES',
),
);
$db = new Horde_Db_Adapter_Mysqli($config);
None found |
quoteString(string $string) : string
Quotes a string, escaping any ' (single quote) and \ (backslash) characters.
.
string | $string |
None found |
select(string $sql, mixed $arg1 = null, string $arg2 = null) : \Horde_Db_Adapter_Mysqli_Result
Returns an array of records with the column names as keys, and column values as values.
string | $sql | |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
execute(string $sql, mixed $arg1 = null, string $arg2 = null) : \mysqli_result
Executes the SQL statement in the context of this connection.
string | $sql | SQL statement. |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
None found |
insert(string $sql, mixed $arg1 = null, string $arg2 = null, string $pk = null, integer $idValue = null, string $sequenceName = null)
Returns the last auto-generated ID from the affected table.
string | $sql | |
mixed | $arg1 | Either an array of bound parameters or a query name. |
string | $arg2 | If $arg1 contains bound parameters, the query name. |
string | $pk | |
integer | $idValue | |
string | $sequenceName |
None found |
None found |
None found |
rollbackDbTransaction()
Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
None found |
_checkRequiredConfig(array $required)
Checks if required configuration keys are present.
array | $required | Required configuration keys. |
if a required key is missing.
None found |
_replaceParameters(string $sql, array $args, boolean $no_binary = false) : string
Replace ? in a SQL statement with quoted values from $args
string | $sql | SQL statement. |
array | $args | An array of values to bind. |
boolean | $no_binary | If true, do not replace any Horde_Db_Value_Binary values. Used for logging purposes. |
Modified SQL statement.
None found |
_logInfo(string $sql, array $values, string $name = null, float $runtime = null)
Logs the SQL query for debugging.
string | $sql | SQL statement. |
array | $values | An array of values to substitute for placeholders. |
string | $name | Optional queryname. |
float | $runtime | Runtime interval. |
None found |
None found |
_formatLogEntry(string $message, string $sql) : string
Formats the log entry.
string | $message | Message. |
string | $sql | SQL statment. |
Formatted log entry.
None found |
_cacheKey(string $key) : string
Returns the prefixed cache key to use.
string | $key | A cache key. |
Prefixed cache key.
None found |