KWeb
6.4
|
Public Member Functions | |
__construct (array $params) | |
connect () | |
disconnect () | |
getDatabase () | |
Returns default database for this connection. | |
getCurrentDatabase () | |
setDatabase ($db) | |
Sets default database for this connection. | |
resetDatabase () | |
Resets this connection's database to default. | |
useDatabase ($db) | |
Temporarly uses specified database. | |
getEncoding () | |
isConnected () | |
getVersion () | |
isVersion ($v) | |
inTransaction () | |
Returns the transactions stack depth. | |
isFailedTransaction ($setFailed=null) | |
Returns true if current transaction is failed. | |
parseSql (&$sql, &$bind, &$opts) | |
execute ($sql, array $bind=array(), array $opts=array()) | |
Executes query and returns the number of affected rows. | |
query ($sql, array $bind=array(), array $opts=array()) | |
Like execute, but returns the object for row fetching. | |
begin () | |
Starts nested transactions. | |
commit () | |
Commits nested transactions. | |
isUsingTransactions () | |
isInTransaction () | |
rollback ($instantly=false) | |
Flags the transactions stack as failed. | |
markFailed () | |
Marks the transaction as failed. | |
getError ($result=null) | |
Returns error message for the query result (specified, or last if null) | |
getAffectedRows () | |
Returns the number of affected rows by last query/execute. | |
getLastInsertId () | |
Returns last insert ID. | |
closeResult ($result=null) | |
Closes query result (specified, or last if null) | |
fetchRow ($result=null, array $opts=array()) | |
Fetches one whole row from the query result (specified, or last if null), and moves to the next row. | |
fetchValue ($result=null, $column=0, array $opts=array()) | |
Fetches single column's value from the query result (specified, or last if null), and moves to the next row. | |
seekToRow ($row, $result=null) | |
Moves to specified row. | |
getRowCount ($result=null) | |
getColumnCount ($result=null) | |
getColumnInfo ($column, $result=null) | |
Enter description here ... | |
findColumnInData (array &$data, $column, $returnValue, $result=null) | |
Finds specified column in supplied data, and returns either key or value. | |
queryValue ($sql, $column=0, array $bind=array(), array $opts=array()) | |
queryValues ($sql, $column=0, array $bind=array(), array $opts=array()) | |
queryRow ($sql, array $bind=array(), array $opts=array()) | |
queryRows ($sql, array $bind=array(), array $opts=array()) | |
queryKeyValue ($sql, $multipleValues=false, array $bind=array(), array $opts=array(), $keyColumn=0, $valueColumn=1) | |
Returns the result as array(key => value), or array(key => array(value,value,...)) | |
queryKeyRow ($sql, $multipleRows=false, array $bind=array(), array $opts=array(), $keyColumn=0) | |
Return the result as array(key => row), or array(key => array(row, row...)) | |
quote ($value, $handleTypes=true) | |
quoteArray ($arr, $handleTypes=true) | |
buildValues ($tab, $glue, $escape=true, $handleTypes=true) | |
Quotes and glues values together. | |
insertOrUpdate ($table, $where, $insert, $update=false, $insertFirst=false, $escape=false) | |
Checks if the values are already in a database with constraints in $where. | |
queryAssocRows ($sql, $multi=false) | |
queryAssoc ($sql, $multi=false, $assoc=0) | |
connected () | |
sql_query ($sql= '') | |
sql_fetchrow ($result=null, $type=MYSQL_BOTH) | |
sql_nextid () | |
sql_freeresult ($result=null) | |
sql_close () | |
sql_error_msg ($result=null) | |
success () | |
sql_affectedrows () | |
Data Fields | |
$gotError = false | |
True if the error was cought. | |
$queriesCount = 0 | |
$queriesPreparedCount = 0 | |
$queriesHitCount = 0 | |
$resultsHitCount = 0 | |
$resultsCachedCount = 0 | |
$queryTimeLimit = 0 | |
$queries = array() | |
$logQueries = true | |
$logLimit = 300 | |
$currentDatabase | |
$database | |
$encoding | |
Protected Member Functions | |
onError (KDBException $exception) | |
Called in case of any error - in SQL queries, on connection etc. | |
doQuery ($sql, array $bind=array(), array $opts=array()) | |
doUseDatabase ($db) | |
doBegin () | |
doCommit () | |
doRollback () | |
getCacheObject ($sql, $unique, array $bind=array(), array $opts=array()) | |
readCachedResult ($cache, array $opts=array()) | |
storeCachedResult ($cache, &$data) | |
Protected Attributes | |
$useTransactions = false | |
Should transactions be used? | |
$transaction = 0 | |
Depth of the transaction stack. | |
$transactionFailed = false | |
True if the current transaction stack is marked as failed. | |
$useDriver = null | |
$params |
KDB_Driver::__construct | ( | array $ | params | ) |
$params | Connection parameters ( |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::begin | ( | ) |
Starts nested transactions.
Transactions are commited ONLY when all started transactions are marked for commit.
Any rollback(), or SQL error between will mark whole transactions stack as failed and will ROLLBACK on the last commit/rollback call.
It's also possible to rollback in an instant. This will issue ROLLBACK to the database and create new TRANSACTION while keeping current transactions stack intact (and in failed state)
KDB_Driver::buildValues | ( | $ | tab, |
$ | glue, | ||
$ | escape = true , |
||
$ | handleTypes = true |
||
) |
Quotes and glues values together.
array | $tab | - values to work on. If hashmap is passed, sql will be built as NAME = VALUE GLUE NAME = ... |
string | $glue | - separator to use, like ', ' or ' AND ' etc. |
boolean | $escape | - should the values be quoted? |
boolean | $correctDouble | - should the doubles be corrected (in some locales decimals are marked with ',' instead of '.') |
KDB_Driver::closeResult | ( | $ | result = null | ) | [abstract] |
Closes query result (specified, or last if null)
$result | Object/resource returned from query() or null to use the last one | |
unknown_type | $result |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::commit | ( | ) |
Commits nested transactions.
It's invoked at the very end of the transactions stack.
If error occured, or rollback was used before - it uses ROLLBACK instead of COMMIT
KDB_Driver::connect | ( | ) | [abstract] |
KDBException |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::connected | ( | ) |
KDB_Driver::disconnect | ( | ) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::doBegin | ( | ) | [abstract, protected] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::doCommit | ( | ) | [abstract, protected] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::doQuery | ( | $ | sql, |
array $ | bind = array() , |
||
array $ | opts = array() |
||
) | [abstract, protected] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::doRollback | ( | ) | [abstract, protected] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::doUseDatabase | ( | $ | db | ) | [protected] |
KDB_Driver::execute | ( | $ | sql, |
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
Executes query and returns the number of affected rows.
string | $query | |
array | $bind | Parameters to bind to the statement |
array | $opts | Hashmap with additional options like KDB::OPT_PREPARE |
KDBException |
KDB_Driver::fetchRow | ( | $ | result = null , |
array $ | opts = array() |
||
) | [abstract] |
Fetches one whole row from the query result (specified, or last if null), and moves to the next row.
$result | Object/resource returned from query() or null to use the last one | |
array | $opts | Additional options like KDB::OPT_FETCH |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::fetchValue | ( | $ | result = null , |
$ | column = 0 , |
||
array $ | opts = array() |
||
) |
Fetches single column's value from the query result (specified, or last if null), and moves to the next row.
$result | Object/resource returned from query() or null to use the last one | |
$column | Column to fetch (index or name) | |
array | $opts | Additional options like KDB::OPT_FETCH |
KDB_Driver::findColumnInData | ( | array &$ | data, |
$ | column, | ||
$ | returnValue, | ||
$ | result = null |
||
) |
Finds specified column in supplied data, and returns either key or value.
array | $data | |
$column | - column as 0-based index or name | |
boolean | $returnValue | - TRUE to return value, FALSE to return key |
$result | - result object from query(). Drivers may use it for help... |
KDB_Driver::getAffectedRows | ( | ) | [abstract] |
Returns the number of affected rows by last query/execute.
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getCacheObject | ( | $ | sql, |
$ | unique, | ||
array $ | bind = array() , |
||
array $ | opts = array() |
||
) | [protected] |
KDB_Driver::getColumnCount | ( | $ | result = null | ) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getColumnInfo | ( | $ | column, |
$ | result = null |
||
) | [abstract] |
Enter description here ...
unknown_type | $column | |
unknown_type | $result |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getCurrentDatabase | ( | ) |
KDB_Driver::getDatabase | ( | ) |
Returns default database for this connection.
KDB_Driver::getEncoding | ( | ) |
KDB_Driver::getError | ( | $ | result = null | ) | [abstract] |
Returns error message for the query result (specified, or last if null)
$result | Object/resource returned from query() or null to use the last one |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getLastInsertId | ( | ) | [abstract] |
Returns last insert ID.
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getRowCount | ( | $ | result = null | ) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::getVersion | ( | ) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::insertOrUpdate | ( | $ | table, |
$ | where, | ||
$ | insert, | ||
$ | update = false , |
||
$ | insertFirst = false , |
||
$ | escape = false |
||
) |
Checks if the values are already in a database with constraints in $where.
If they are - executes UPDATE with data from $update, or with $insert if $update is empty
If they are not - executes INSERT with data from $insert AND $where
This is different than REPLACE - it allows to run different SQL when updating then the SQL when inserting.
string | $table | - table |
array/string | $where - hashmap of values to look for, glued with ' AND ', or SQL string | |
array/string | $insert - hashmap of values to insert, or SQL string | |
array/string/false | $update - hashmap of values to update, or SQL string, or FALSE to use $insert | |
boolean | $insertFirst | - TRUE if checking/updating should be skipped |
boolean | $escape | - TRUE if the values in hashmaps should be escaped, FALSE if not |
KDB_Driver::inTransaction | ( | ) |
Returns the transactions stack depth.
KDB_Driver::isConnected | ( | ) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::isFailedTransaction | ( | $ | setFailed = null | ) |
Returns true if current transaction is failed.
Allows to change the flag.
boolean | $setFailed |
KDB_Driver::isInTransaction | ( | ) |
KDB_Driver::isUsingTransactions | ( | ) |
KDB_Driver::isVersion | ( | $ | v | ) |
KDB_Driver::markFailed | ( | ) |
Marks the transaction as failed.
It will be rolled back on the next commit() call
KDB_Driver::onError | ( | KDBException $ | exception | ) | [protected] |
Called in case of any error - in SQL queries, on connection etc.
KDB_Driver implementation should use this function instead of throwing exceptions directly.
KDBException | $message | |
unknown_type | $query |
KDBException |
KDB_Driver::parseSql | ( | &$ | sql, |
&$ | bind, | ||
&$ | opts | ||
) |
KDB_Driver::query | ( | $ | sql, |
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
Like execute, but returns the object for row fetching.
Type of this object depends on the driver. For PDO it will be PDOStatement, for others may be a resource id.
KDBException |
KDB_Driver::queryAssoc | ( | $ | sql, |
$ | multi = false , |
||
$ | assoc = 0 |
||
) |
KDB_Driver::queryAssocRows | ( | $ | sql, |
$ | multi = false |
||
) |
KDB_Driver::queryKeyRow | ( | $ | sql, |
$ | multipleRows = false , |
||
array $ | bind = array() , |
||
array $ | opts = array() , |
||
$ | keyColumn = 0 |
||
) |
Return the result as array(key => row), or array(key => array(row, row...))
unknown_type | $sql | |
unknown_type | $multipleRows | |
array | $bind | |
array | $opts | |
int/string | $keyColumn |
KDB_Driver::queryKeyValue | ( | $ | sql, |
$ | multipleValues = false , |
||
array $ | bind = array() , |
||
array $ | opts = array() , |
||
$ | keyColumn = 0 , |
||
$ | valueColumn = 1 |
||
) |
Returns the result as array(key => value), or array(key => array(value,value,...))
unknown_type | $sql | |
unknown_type | $multipleValues | |
array | $bind | |
array | $opts | |
int/string | $keyColumn - column with keys | |
int/string | $valueColumn - column with values |
KDB_Driver::queryRow | ( | $ | sql, |
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
KDB_Driver::queryRows | ( | $ | sql, |
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
KDB_Driver::queryValue | ( | $ | sql, |
$ | column = 0 , |
||
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
KDB_Driver::queryValues | ( | $ | sql, |
$ | column = 0 , |
||
array $ | bind = array() , |
||
array $ | opts = array() |
||
) |
KDB_Driver::quote | ( | $ | value, |
$ | handleTypes = true |
||
) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::quoteArray | ( | $ | arr, |
$ | handleTypes = true |
||
) | [abstract] |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::readCachedResult | ( | $ | cache, |
array $ | opts = array() |
||
) | [protected] |
KDB_Driver::resetDatabase | ( | ) |
Resets this connection's database to default.
KDB_Driver::rollback | ( | $ | instantly = false | ) |
Flags the transactions stack as failed.
Rollback is issued on the outermost transaction commit/rollback.
boolean | $instantly | - if TRUE the transaction is rolled back instantly, and the transaction is restarted if there are more transactions in the stack left |
KDB_Driver::seekToRow | ( | $ | row, |
$ | result = null |
||
) | [abstract] |
Moves to specified row.
unknown_type | $row | |
unknown_type | $result |
Reimplemented in KDB_PDO, and KDB_Legacy.
KDB_Driver::setDatabase | ( | $ | db | ) |
Sets default database for this connection.
KDB_Driver::sql_affectedrows | ( | ) |
KDB_Driver::sql_close | ( | ) |
KDB_Driver::sql_error_msg | ( | $ | result = null | ) |
KDB_Driver::sql_fetchrow | ( | $ | result = null , |
$ | type = MYSQL_BOTH |
||
) |
KDB_Driver::sql_freeresult | ( | $ | result = null | ) |
KDB_Driver::sql_nextid | ( | ) |
KDB_Driver::sql_query | ( | $ | sql = '' | ) |
KDB_Driver::storeCachedResult | ( | $ | cache, |
&$ | data | ||
) | [protected] |
KDB_Driver::success | ( | ) |
KDB_Driver::useDatabase | ( | $ | db | ) |
Temporarly uses specified database.
KDB_Driver::$currentDatabase |
KDB_Driver::$database |
KDB_Driver::$encoding |
KDB_Driver::$gotError = false |
True if the error was cought.
Can be reset by clients at will.
KDB_Driver::$logLimit = 300 |
KDB_Driver::$logQueries = true |
KDB_Driver::$params [protected] |
KDB_Driver::$queries = array() |
KDB_Driver::$queriesCount = 0 |
KDB_Driver::$queriesHitCount = 0 |
KDB_Driver::$queriesPreparedCount = 0 |
KDB_Driver::$queryTimeLimit = 0 |
KDB_Driver::$resultsCachedCount = 0 |
KDB_Driver::$resultsHitCount = 0 |
KDB_Driver::$transaction = 0 [protected] |
Depth of the transaction stack.
KDB_Driver::$transactionFailed = false [protected] |
True if the current transaction stack is marked as failed.
KDB_Driver::$useDriver = null [protected] |
KDB_Driver::$useTransactions = false [protected] |
Should transactions be used?