Помогите разобраться, как сообщить объекту PDOStatement, что бы тот отдал при SELECT, SHOW, DESCRIBE или EXPLAIN массив, а при остальных TRUE или FALSE?
Ниже приведу метод который я использую для SELECT.
class Database extends Api
{
public $settings = [
'host' => '',
'name' => '',
'user' => '',
'pass' => ''
];
private $pdo = null;
public function query ( $string )
{
$response = null;
if ( !$this->settings['host'] || !$this->settings['name'] || !$this->settings['user'] || !$this->settings['pass'] || !$string )
return $response;
elseif ( !$this->pdo )
$this->pdo = new PDO( 'mysql:host='. $this->settings['host'] .';dbname='. $this->settings['name'], $this->settings['user'], $this->settings['pass'] );
$response = $this->pdo->query( $string );
if ( !$response ) return false;
$response->rows = [];
while( $row = $response->fetch( PDO::FETCH_ASSOC ) ){ $response->rows[] = $row; }
return $response;
}
}
Спасибо за ответы.