Returns an instance of the database connection to the JobRouter database on which you can then execute SQL commands using the JobRouter database.
If an error occurs, the function throws a JobRouterException.
Example:
$jobDB = $this->getJobDB();
$result = $jobDB->preparedSelect(
'SELECT username FROM JRUSERS WHERE blocked = :blocked',
['blocked' => 1],
[ConnectionInterface::TYPE_INTEGER],
);
$blockedUsers = $result->fetchAll();
The object has following methods:
Methode |
Parameter |
Rückgabe |
Beschreibung |
|---|---|---|---|
preparedSelect |
string $sql, array $params, ?array $types = [] |
Execute a query with optional parameters (select). The parameters are quoted according to the column type. |
|
preparedExecute |
string $sql, array $params, ?array $types = [] |
Execute a statement with optional parameters (insert, update or delete). The parameters are quoted according to the column type.
Beispiel: $jobDB->preparedExecute( 'UPDATE CATEGORIES SET name = :name WHERE id = :id', ['name' => 'Archiviert', 'id' => 10], [JobRouter\Common\Database\ConnectionInterface::TYPE_TEXT, JobRouter\Common\Database\ConnectionInterface::TYPE_INTEGER], );
|
|
query |
$statement |
Result object |
Use this method to read data by passing an SQL select query. |
exec |
$statement |
Integer |
Use this method to change data by passing an insert, update or delete statement. |
quote |
$value |
String |
Converts the passed value to a DBMS-specific format suitable for query statements. |
fetchAll |
$result |
Array |
This method returns all rows of the query result. |
fetchRow |
$result |
Array | false |
This method returns the next record as an associative array. If no more records are available the method returns false. |
fetchOne |
$result |
String |
This method returns the first column of the next record. |
getErrorMessage |
- |
String |
Returns the last error. |