for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Result class for mysql driver
*
* @author Alexey Krupskiy <[email protected]>
* @link http://inji.ru/
* @copyright 2015 Alexey Krupskiy
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
*/
namespace Inji\Db\Mysql;
use Inji\Db\DriverResult;
class Result implements DriverResult {
fetchAll
public $pdoResult = null;
public function __construct($dbResult) {
$this->pdoResult = $dbResult;
}
public function getArray($keyCol = '') {
$key = \Inji\App::$cur->log->start('parse result');
if (!$keyCol) {
return $this->pdoResult->fetchAll(\PDO::FETCH_ASSOC);
$array = [];
while ($row = $this->pdoResult->fetch(\PDO::FETCH_ASSOC)) {
if (isset($row[$keyCol])) {
$array[$row[$keyCol]] = $row;
} else {
$array[] = $row;
\Inji\App::$cur->log->end($key);
return $array;
public function getObjects($class, $keyCol = '') {
while ($object = $this->pdoResult->fetchObject($class)) {
if ($keyCol) {
$array[$object->$keyCol] = $object;
$array[] = $object;
public function fetch($className = '') {
if ($className) {
return $this->pdoResult->fetchObject($className);
return $this->pdoResult->fetch(\PDO::FETCH_ASSOC);