PHP Class Horde_Db_Adapter_Mysqli, horde

Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: extends Horde_Db_Adapter_Base
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_hasMysqliFetchAll boolean
$_insertId integer Last auto-generated insert_id
$_schemaClass string

Public Methods

Method Description
adapterName ( ) : string Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
beginDbTransaction ( ) Begins the transaction (and turns off auto-committing).
commitDbTransaction ( ) Commits the transaction (and turns on auto-committing).
connect ( ) Connect to the db
disconnect ( ) Disconnect from db
execute ( string $sql, mixed $arg1 = null, string $arg2 = null ) : mysqli_result Executes the SQL statement in the context of this connection.
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.
isActive ( ) : boolean Check if the connection is active
quoteString ( string $string ) : string Quotes a string, escaping any ' (single quote) and \ (backslash) characters.
rollbackDbTransaction ( ) Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
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.
selectAll ( string $sql, mixed $arg1 = null, string $arg2 = null ) Returns an array of record hashes with the column names as keys and column values as values.
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.
selectValue ( string $sql, mixed $arg1 = null, string $arg2 = null ) : string Returns a single value from a record
selectValues ( string $sql, mixed $arg1 = null, string $arg2 = null ) Returns an array of the values of the first column in a select: select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
supportsMigrations ( ) : boolean Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.

Protected Methods

Method Description
_errorCode ( string $sqlstate, integer $errno ) : integer Return a standard error code
_parseConfig ( ) : array Parse configuration array into options for MySQLi constructor.

Method Details

_errorCode() protected method

Return a standard error code
protected _errorCode ( string $sqlstate, integer $errno ) : integer
$sqlstate string
$errno integer
return integer

_parseConfig() protected method

Parse configuration array into options for MySQLi constructor.
protected _parseConfig ( ) : array
return array [host, username, password, dbname, port, socket]

adapterName() public method

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
public adapterName ( ) : string
return string

beginDbTransaction() public method

Begins the transaction (and turns off auto-committing).
public beginDbTransaction ( )

commitDbTransaction() public method

Commits the transaction (and turns on auto-committing).
public commitDbTransaction ( )

connect() public method

MySQLi can connect using SSL if $config contains an 'ssl' sub-array containing the following keys: + key The path to the key file. + cert The path to the certificate file. + ca The path to the certificate authority file. + capath The path to a directory that contains trusted SSL CA certificates in pem format. + cipher The list of allowable ciphers for SSL encryption. 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);
public connect ( )

disconnect() public method

Disconnect from db
public disconnect ( )

execute() public method

Executes the SQL statement in the context of this connection.
Deprecation: Deprecated for external usage. Use select() instead.
public execute ( string $sql, mixed $arg1 = null, string $arg2 = null ) : mysqli_result
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return mysqli_result

insert() public method

Returns the last auto-generated ID from the affected table.
public insert ( string $sql, mixed $arg1 = null, string $arg2 = null, string $pk = null, integer $idValue = null, string $sequenceName = null )
$sql string
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
$pk string
$idValue integer
$sequenceName string

isActive() public method

Check if the connection is active
public isActive ( ) : boolean
return boolean

quoteString() public method

.
public quoteString ( string $string ) : string
$string string
return string

rollbackDbTransaction() public method

Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.

select() public method

Returns an array of records with the column names as keys, and column values as values.
public select ( string $sql, mixed $arg1 = null, string $arg2 = null ) : Horde_Db_Adapter_Mysqli_Result
$sql string
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return Horde_Db_Adapter_Mysqli_Result

selectAll() public method

Returns an array of record hashes with the column names as keys and column values as values.
public selectAll ( string $sql, mixed $arg1 = null, string $arg2 = null )
$sql string
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.

selectOne() public method

Returns a record hash with the column names as keys and column values as values.
public selectOne ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array | boolean
$sql string A query.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return array | boolean A record hash or false if no record found.

selectValue() public method

Returns a single value from a record
public selectValue ( string $sql, mixed $arg1 = null, string $arg2 = null ) : string
$sql string
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return string

selectValues() public method

Returns an array of the values of the first column in a select: select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
public selectValues ( string $sql, mixed $arg1 = null, string $arg2 = null )
$sql string
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.

supportsMigrations() public method

Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.
public supportsMigrations ( ) : boolean
return boolean

Property Details

$_hasMysqliFetchAll protected_oe property

protected bool $_hasMysqliFetchAll
return boolean

$_insertId protected_oe property

Last auto-generated insert_id
protected int $_insertId
return integer

$_schemaClass protected_oe property

protected string $_schemaClass
return string