Class DibiMySqliDriver


The dibi driver for MySQL database via improved extension.

Driver options:

  • host => the MySQL server host name
  • port (int) => the port number to attempt to connect to the MySQL server
  • socket => the socket or named pipe
  • username (or user)
  • password (or pass)
  • database => the database name to select
  • options (array) => array of driver specific constants (MYSQLI_*) and values {@see mysqli_options}
  • flags (int) => driver specific constants (MYSQLI_CLIENT_*) {@see mysqli_real_connect}
  • charset => character encoding to set (default is utf8)
  • persistent (bool) => try to find a persistent link?
  • unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
  • sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
  • resource (mysqli) => existing connection resource
  • lazy, profiler, result, substitutes, ... => see DibiConnection options

DibiObject
   |
   --DibiMySqliDriver

Implements interfaces:

IDibiDriver, IDibiResultDriver
Copyright: Copyright (c) 2005, 2010 David Grudl
Located: in /drivers/mysqli.php (line 39)
Constructor Summary
public
Method Summary
void
applyLimit (string &$sql, int $limit, int $offset)
Injects LIMIT/OFFSET to the SQL query.
void
begin ([string $savepoint = NULL])
Begins a transaction (if supported).
void
commit ([string $savepoint = NULL])
Commits statements in a transaction.
void
connect (&$config)
Connects to a database.
void
Disconnects from a database.
string
escape (mixed $value, string $type)
Encodes data for use in a SQL statement.
string
escapeLike (string $value, int $pos)
Encodes string for use in a LIKE statement.
array
fetch (bool $assoc)
Fetches the row at current position and moves the internal cursor to the next position.
void
free ()
Frees the resources allocated for this result set.
int|FALSE
Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
array
getInfo ()
Retrieves information about the most recently executed query.
int|FALSE
getInsertId ($sequence)
Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
IDibiReflector
Returns the connection reflector.
mysqli
Returns the connection resource.
array
Returns metadata for all columns in a result set.
mysqli_result
Returns the result set resource.
int
Returns the number of rows in a result set.
IDibiResultDriver|NULL
query (string $sql)
Executes the SQL query.
void
rollback ([string $savepoint = NULL])
Rollback changes in a transaction.
boolean
seek (int $row)
Moves cursor position without fetching row.
string
unescape (string $value, string $type)
Decodes data from result set.
Methods Inherited From DibiObject
DibiObject::extensionMethod(), DibiObject::getClass(), DibiObject::getReflection(), DibiObject::__call(), DibiObject::__callStatic(), DibiObject::__get(), DibiObject::__isset(), DibiObject::__set(), DibiObject::__unset()
Constant Summary
int ERROR_ACCESS_DENIED 1045

line 41

int ERROR_DATA_TRUNCATED 1265

line 43

int ERROR_DUPLICATE_ENTRY 1062

line 42


Constructor Details

line 59

__construct

public __construct ()

Method Details

line 348

applyLimit

public void applyLimit (string &$sql, int $limit, int $offset)

Injects LIMIT/OFFSET to the SQL query.

Input
string &$sql The SQL query that will be modified.
int $limit
int $offset
Output
void  

line 216

begin

public void begin ([string $savepoint = NULL])

Begins a transaction (if supported).

Input
string $savepoint optional savepoint name
Output
void  
Throws
throws DibiDriverException

line 229

commit

public void commit ([string $savepoint = NULL])

Commits statements in a transaction.

Input
string $savepoint optional savepoint name
Output
void  
Throws
throws DibiDriverException

line 73

connect

public void connect (&$config)

Connects to a database.

Input
&$config
Output
void  
Throws
throws DibiException

line 144

disconnect

public void disconnect ()

Disconnects from a database.

Output
void  

line 282

escape

public string escape (mixed $value, string $type)

Encodes data for use in a SQL statement.

Input
mixed $value value
string $type type (dibi::TEXT, dibi::BOOL, ...)
Output
string encoded value
Throws
throws InvalidArgumentException

line 316

escapeLike

public string escapeLike (string $value, int $pos)

Encodes string for use in a LIKE statement.

Input
string $value
int $pos
Output
string  

line 382

fetch

public array fetch (bool $assoc)

Fetches the row at current position and moves the internal cursor to the next position.

Input
bool $assoc TRUE for associative array, FALSE for numeric
Output
array array on success, nonarray if no next record

line 409

free

public void free ()

Frees the resources allocated for this result set.

Output
void  

line 192

getAffectedRows

public int|FALSE getAffectedRows ()

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.

Output
int|FALSE number of rows or FALSE on error

line 174

getInfo

public array getInfo ()

Retrieves information about the most recently executed query.

Output
array  

line 203

getInsertId

public int|FALSE getInsertId ($sequence)

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.

Input
$sequence
Output
int|FALSE int on success or FALSE on failure

line 264

getReflector

public IDibiReflector getReflector ()

Returns the connection reflector.

Output
IDibiReflector  

line 253

getResource

public mysqli getResource ()

Returns the connection resource.

Output
mysqli  

line 421

getResultColumns

public array getResultColumns ()

Returns metadata for all columns in a result set.

Output
array  

line 455

getResultResource

public mysqli_result getResultResource ()

Returns the result set resource.

Output
mysqli_result  

line 367

getRowCount

public int getRowCount ()

Returns the number of rows in a result set.

Output
int  

line 157

query

public IDibiResultDriver|NULL query (string $sql)

Executes the SQL query.

Input
string $sql SQL statement.
Output
IDibiResultDriver|NULL  
Throws
throws DibiDriverException

line 242

rollback

public void rollback ([string $savepoint = NULL])

Rollback changes in a transaction.

Input
string $savepoint optional savepoint name
Output
void  
Throws
throws DibiDriverException

line 395

seek

public boolean seek (int $row)

Moves cursor position without fetching row.

Input
int $row the 0-based cursor pos to seek to
Output
boolean TRUE on success, FALSE if unable to seek to specified record
Throws
throws DibiException

line 331

unescape

public string unescape (string $value, string $type)

Decodes data from result set.

Input
string $value value
string $type type (dibi::BINARY)
Output
string decoded value
Throws
throws InvalidArgumentException