Dotclear 2.24
|
Database Abstraction Layer class. More...
Public Member Functions | |
__construct (string $host, string $database, string $user='', string $password='', bool $persistent=false) | |
close () | |
driver () | |
syntax () | |
version () | |
database () | |
link () | |
select (string $sql) | |
nullRecord () | |
execute (string $sql) | |
begin () | |
commit () | |
rollback () | |
writeLock (string $table) | |
unlock () | |
vacuum (string $table) | |
changes () | |
error () | |
dateFormat (string $field, string $pattern) | |
limit ($arg1, ?int $arg2=null) | |
in ($in) | |
orderBy (... $args) | |
lexFields (... $args) | |
concat (... $args) | |
escape ($i) | |
escapeSystem (string $str) | |
openCursor (string $table) | |
Static Public Member Functions | |
static | init (string $driver, string $host, string $database, string $user='', string $password='', bool $persistent=false) |
Protected Attributes | |
$__driver | |
$__syntax | |
$__version | |
string: Database version More... | |
$__link | |
$__last_result | |
$__database | |
Database Abstraction Layer class.
Base class for database abstraction. Each driver extends this class and implements i_dbLayer
interface.
__construct | ( | string | $host, |
string | $database, | ||
string | $user = '' , |
||
string | $password = '' , |
||
bool | $persistent = false |
||
) |
string | $host | Database hostname |
string | $database | Database name |
string | $user | User ID |
string | $password | Password |
bool | $persistent | Persistent connection |
|
static |
Start connection
Static function to use to init database layer. Returns a object extending dbLayer.
string | $driver | Driver name |
string | $host | Database hostname |
string | $database | Database name |
string | $user | User ID |
string | $password | Password |
bool | $persistent | Persistent connection |
References exit.
Referenced by dcCore\__construct(), dcImportDC1\db(), and dcImportWP\db().
close | ( | ) |
Closes database connection.
driver | ( | ) |
syntax | ( | ) |
version | ( | ) |
database | ( | ) |
link | ( | ) |
select | ( | string | $sql | ) |
Run query and get results
Executes a query and return a record
object.
string | $sql | SQL query |
Reimplemented in sqliteConnection.
Referenced by pgsqlConnection\callFunction().
nullRecord | ( | ) |
execute | ( | string | $sql | ) |
Run query
Executes a query and return true if succeed
string | $sql | SQL query |
Referenced by begin(), commit(), mysqliConnection\db_unlock(), pgsqlConnection\db_unlock(), sqliteConnection\db_unlock(), mysqliConnection\db_write_lock(), pgsqlConnection\db_write_lock(), sqliteConnection\db_write_lock(), rollback(), mysqliConnection\vacuum(), and pgsqlConnection\vacuum().
begin | ( | ) |
Begin transaction
Begins a transaction. Transaction should be commited
or rollbacked
.
Reimplemented in sqliteConnection.
References execute().
commit | ( | ) |
Commit transaction
Commits a previoulsy started transaction.
Reimplemented in sqliteConnection.
References execute().
rollback | ( | ) |
Rollback transaction
Rollbacks a previously started transaction.
Reimplemented in sqliteConnection.
References execute().
writeLock | ( | string | $table | ) |
Aquiere write lock
This method lock the given table in write access.
string | $table | Table name |
unlock | ( | ) |
Release lock
This method releases an acquiered lock.
vacuum | ( | string | $table | ) |
Vacuum the table given in argument.
string | $table | Table name |
Reimplemented in mysqliConnection, pgsqlConnection, and sqliteConnection.
changes | ( | ) |
Changed rows
Returns the number of lines affected by the last DELETE, INSERT or UPDATE query.
error | ( | ) |
Last error
Returns the last database error or false if no error.
References $err.
dateFormat | ( | string | $field, |
string | $pattern | ||
) |
Date formatting
Returns a query fragment with date formater.
The following modifiers are accepted:
string | $field | Field name |
string | $pattern | Date format |
Reimplemented in mysqliConnection, pgsqlConnection, and sqliteConnection.
References escape().
limit | ( | $arg1, | |
?int | $arg2 = null |
||
) |
Query Limit
Returns a LIMIT query fragment. $arg1 could be an array of offset and limit or an integer which is only limit. If $arg2 is given and $arg1 is an integer, it would become limit.
array | int | $arg1 | array or integer with limit intervals |
int | null | $arg2 | integer or null |
in | ( | $in | ) |
IN fragment
Returns a IN query fragment where $in could be an array, a string, an integer or null
array | string | int | null | $in | "IN" values |
References escape().
orderBy | ( | $args | ) |
ORDER BY fragment
Returns a ORDER BY query fragment where arguments could be an array or a string
array param: key : decription field : field name (string) collate : True or False (boolean) (Alphabetical order / Binary order) order : ASC or DESC (string) (Ascending order / Descending order)
string param field name (Binary ascending order)
Reimplemented in mysqliConnection, mysqlimb4Connection, pgsqlConnection, and sqliteConnection.
lexFields | ( | $args | ) |
Field name(s) fragment (using generic UTF8 collating sequence if available else using SQL LOWER function)
Returns a fields list where args could be an array or a string
array param: list of field names string param: field name
Reimplemented in mysqliConnection, mysqlimb4Connection, pgsqlConnection, and sqliteConnection.
concat | ( | $args | ) |
Concat strings
Returns SQL concatenation of methods arguments. Theses arguments should be properly escaped when needed.
Reimplemented in mysqliConnection.
escape | ( | $i | ) |
Escape string
Returns SQL protected string or array values.
string | array | $i | String or array to protect |
Referenced by pgsqlConnection\callFunction(), mysqliConnection\dateFormat(), pgsqlConnection\dateFormat(), sqliteConnection\dateFormat(), dateFormat(), sqliteConnection\escapeSystem(), and in().
escapeSystem | ( | string | $str | ) |
System escape string
Returns SQL system protected string.
string | $str | String to protect |
Reimplemented in mysqliConnection, and sqliteConnection.
Referenced by pgsqlConnection\db_write_lock(), and pgsqlConnection\vacuum().
openCursor | ( | string | $table | ) |
Cursor object
Returns a new instance of cursor
class on $table for the current connection.
string | $table | Target table |
|
protected |
Referenced by driver().
|
protected |
Referenced by syntax().
|
protected |
string: Database version
Referenced by version().
|
protected |
Referenced by link().
|
protected |
|
protected |
Referenced by database().