To fetch data use the method preparedSelect, which you can execute on the previously instantiated $jobDB object.
Parameter |
Type |
Description |
|---|---|---|
$sql |
string |
SQL statement (SELECT statements) |
$parameterValues |
array |
The values that are to be resolved in the SQL statement are stored there. |
$parameterTypes (optional) |
array |
The data types for the values are stored there.
The following data types are available: •text (ConnectionInterface::TYPE_TEXT) •integer (ConnectionInterface::TYPE_INTEGER) •timestamp (ConnectionInterface::TYPE_DATETIME) •decimal (ConnectionInterface::TYPE_DECIMAL) •clob (ConnectionInterface::TYPE_CLOB)
Please note: The order of the values ($parameterValues) must correspond to the order of the data types ($parameterTypes), otherwise incorrect or faulty SQLs may result. We recommend that you specify the data types, even if the parameter is optional. |
As a return value, you will receive an object, that you can use for further processing of the data. Provided that no values are used in the Prepared Statement, false is returned in the case of an error, otherwise a JobRouterException is thrown.
Example:
…
$jobDB = $this->getJobDB();
$sql = 'SELECT username FROM JRUSERS WHERE username = :username AND blocked = :blocked';
$parameters = [
'username' => 'some_username_here',
'blocked' => 0
];
$types = [
JobRouter\Common\Database\ConnectionInterface::TYPE_TEXT,
JobRouter\Common\Database\ConnectionInterface::TYPE_INTEGER,
];
$result = $jobDB->preparedSelect($sql, $parameters, $types);
while($row = $jobDB->fetchRow($result)) {
// handle row
}
…