Helper for execute queries
package | salt\sql |
---|
beginTransaction()
\salt\SaltException |
if PDO->beginTransaction() failed |
---|
checkAllTransactionsEnded()
\salt\SaltException |
if one transaction is in progress |
---|
checkPassword(string $name, string $pass) : boolean
string
id of a registered database
string
password to check
boolean
TRUE if successfull connect to database with this passwordcommit()
\salt\SaltException |
---|
execCountQuery(\salt\Query $query) : integer
\salt\Query
the query to execute
integer
number of rowsexecCreate(\salt\CreateTableQuery $query)
\salt\CreateTableQuery
the CreateTable query
\salt\SaltException |
if called during a transaction |
---|
execDelete(\salt\DeleteQuery $query, integer $expected = -1
) : integer
\salt\DeleteQuery
the query to execute
integer
number of expected delete, NULL for unknown
\salt\RowCountException |
if delete don't change the expected number of rows |
---|
integer
the number of rows deletedexecInsert(\salt\InsertQuery $query) : string
\salt\InsertQuery
the query to execute
\salt\RowCountException |
if query don't insert the expected number of objects |
---|
string
\PDO::lastInsertId()execQuery(\salt\Query $query, \salt\Pagination $pagination= NULL
, \salt\Base $bindingObject= NULL
) : \salt\DBResult
If $pagination is provided and not locked, a count query is also executed
\salt\Query
the query
\salt\Pagination
Pagination object.
\salt\Base
(Optional) bind to another object type. All returned objects are in NEW state instead of LOADED
\salt\DBResult
result of the queryexecSQL(string $sql, array $binds= array()
, integer|NULL $expectedRows= NULL
) : \salt\SqlStatement
string
sql text
array
array of placeholder (key => value). If we want to set the type for bind a value, we can suffix the key by @
followed by a PDOPARAM* constant
For example : Par exemple, array(':param@'.PDO::PARAM_INT => 3)
value can also be an array with two keys for compatibily with classic queries : array('value' => value, 'type' => FieldType)
integer
NULL
check the number of rows affected by the query. NULL for ignoring
\salt\SqlStatement
Statement after query executionexecUpdate(\salt\UpdateQuery $query, integer $expected = -1
) : integer
\salt\UpdateQuery
integer
number of expected modified rows. NULL if unknown
integer
number of modified rows.getDatabase(string $type = NULL
) : string
string
id of a previously registered database, or NULL for default registered database
\salt\SaltException |
if $type is unknown |
---|
string
database namegetInstance(string $type = NULL
) : \salt\DBHelper
string
id of a previously registered database, or NULL for default registered database
\salt\SaltException |
if $type is unknown or connexion failed |
---|
\salt\DBHelper
the database resourcegetLastError() : array | boolean
array
boolean
getLastId(string $name = NULL
) : string
inTransaction() : boolean
boolean
TRUE if we are in a transactionregister(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset, array $options = array()
)
see | for mysql charset list |
---|
string
the id of the database. Used for retrieve the instance with DBHelper::getInstance(name)
string
host name
string
port
string
database name
string
user name
string
password of user
string
charset of database
array
PDO options array
registerDefault(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset, array $options = array()
)
see | for mysql charset list |
---|
string
the id of the database. Used for retrieve the instance with DBHelper::getInstance()
string
host name
string
port
string
database name
string
user name
string
password of user
string
charset of database
array
PDO options array
\salt\SaltException |
if database already defined |
---|
rollback()
\salt\SaltException |
---|
__construct(\PDO $pdo, string $type)
\PDO
the PDO instance to use in this DBHelper instance
string
type of the instance
addDebugData(string $sql, array<mixed,mixed> $binds, float|NULL $temps)
string
SQL text query (can be count or not count query)
array<mixed,mixed>
placeholders (key => value)
float
NULL
execution time or NULL if query failed
exec(\salt\Query $query, boolean $count= FALSE
, \salt\Pagination $pagination= NULL
) : \salt\SqlStatement
\salt\Query
the query
boolean
true if count query have to be executed
\salt\Pagination
pagination if required
\salt\DBException |
if prepare or execute query failed with a PDOException |
---|---|
\salt\SaltException |
if something else failed |
\salt\SqlStatement
the statement after executionflattenSqlQuery(string $sql, array<mixed,mixed> $binds) : string
string
SQL query string
array<mixed,mixed>
binds, in multiple format, as input/output parameter
string
modified SQL query string$allDatas : array<mixed,\salt\DBConnexion>
array()
$allInstances : array<mixed,\salt\DBHelper>
array()
$base : \PDO
NULL
$default : string
NULL
$txLevel : integer
0
$txRollback : boolean
false
$type : string
NULL