Helper for execute queries
| package | salt\sql |
|---|
beginTransaction()
\Exception |
if PDO->beginTransaction() failed |
|---|
checkAllTransactionsEnded()
\salt\SaltException |
if one transaction is in progress |
|---|
checkPassword(string $name, string $pass) : boolean
stringid of a registered database
stringpassword to check
booleanTRUE if successfull connect to database with this passwordcommit()
\salt\SaltException |
|---|
execCountQuery(\salt\Query $query) : integer
\salt\Querythe query to execute
integernumber of rowsexecCreate(\salt\CreateTableQuery $query)
\salt\CreateTableQuerythe CreateTable query
\Exception |
if called during a transaction |
|---|
execDelete(\salt\DeleteQuery $query, integer $expected = -1) : integer
\salt\DeleteQuerythe query to execute
integernumber of expected delete, NULL for unknown
\salt\RowCountException |
if delete don't change the expected number of rows |
|---|
integerthe number of rows deletedexecInsert(\salt\InsertQuery $query) : string
\salt\InsertQuerythe query to execute
\salt\RowCountException |
if query don't insert the expected number of objects |
|---|
string\PDOStatement::lastInsertId()execQuery(\salt\Query $query, \salt\Pagination $pagination = NULL) : \salt\DBResult
If $pagination is provided and not locked, a count query is also executed
\salt\Querythe query
\salt\PaginationPagination object.
\salt\DBResultresult of the queryexecSQL(string $sql, array $binds = array()) : \PDOStatement
stringsql text
arrayarray 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)
\PDOStatement\PDOStatement after query executionexecUpdate(\salt\UpdateQuery $query, integer $expected = -1) : \salt\number
\salt\UpdateQuery
integernumber of expected modified rows. NULL if unknown
\salt\numberof modified rows.getInstance(string $type = NULL) : \salt\DBHelper
stringid of a previously registered database, or NULL for default registered database
\Exception |
if $type is unknown |
|---|---|
\salt\SaltException |
if connexion failed |
\salt\DBHelperthe database resourceregister(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset = CHARSET)
stringthe id of the database. Used for retrieve the instance with DBHelper::getInstance(name)
stringhost name
stringport
stringdatabase name
stringuser name
stringpassword of user
stringcharset of database
\Exception |
if database already defined |
|---|
registerDefault(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset = CHARSET)
stringthe id of the database. Used for retrieve the instance with DBHelper::getInstance()
stringhost name
stringport
stringdatabase name
stringuser name
stringpassword of user
stringcharset of database
\Exception |
if database already defined |
|---|
rollback()
\salt\SaltException |
|---|
__construct(\PDO $pdo)
\PDOthe PDO instance to use in this DBHelper instance
addDebugData(string $sql, array<mixed,mixed> $binds, float|NULL $temps)
stringSQL text query (can be count or not count query)
array<mixed,mixed>placeholders (key => value)
floatNULLexecution time or NULL if query failed
exec(\salt\Query $query, boolean $count= false, \salt\Pagination $pagination= NULL) : \PDOStatement
\salt\Querythe query
booleantrue if count query have to be executed
\salt\Paginationpagination if required
\salt\DBException |
if prepare or execute query failed with a PDOException |
|---|---|
\Exception |
if something else failed |
\PDOStatementthe PDOStatement after execution$allDatas : array<mixed,\salt\DBConnexion>
array()$allInstances : array<mixed,\salt\DBHelper>
array()$base : \PDO
NULL$default : string
NULL$txLevel : integer
0$txRollback : boolean
false