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
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
\Exception |
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
\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\Query
the query
\salt\Pagination
Pagination object.
\salt\DBResult
result of the queryexecSQL(string $sql, array $binds = array()
) : \PDOStatement
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)
\PDOStatement
\PDOStatement after query executionexecUpdate(\salt\UpdateQuery $query, integer $expected = -1
) : \salt\number
\salt\UpdateQuery
integer
number of expected modified rows. NULL if unknown
\salt\number
of modified rows.getInstance(string $type = NULL
) : \salt\DBHelper
string
id of a previously registered database, or NULL for default registered database
\Exception |
if $type is unknown |
---|---|
\salt\SaltException |
if connexion failed |
\salt\DBHelper
the database resourceregister(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset = CHARSET
)
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
\Exception |
if database already defined |
---|
registerDefault(string $name, string $host, string $port, string $db, string $user, string $pass, string $charset = CHARSET
)
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
\Exception |
if database already defined |
---|
rollback()
\salt\SaltException |
---|
__construct(\PDO $pdo)
\PDO
the PDO instance to use in this DBHelper 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
) : \PDOStatement
\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 |
---|---|
\Exception |
if something else failed |
\PDOStatement
the 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