cphalcon
cphalcon copied to clipboard
PDO FetchMode feature
$pdo = new \Phalcon\Db\Adapter\Pdo\Mysql($config->database->toArray());
$pdo->setFetchMode(Phalcon\Db::FETCH_ASSOC);
I know that I used this improperly, but there should be posibility to set fetch mod for all queries. Is there any? Or could someone add that? It is sick to use this for every query when I use only assoc arrays.
You can override the query method to assign that to every resultset produced:
<?php
class MysqlAdapter extends \Phalcon\Db\Adapter\Pdo\Mysql
{
public function query($sqlStatement, $bindParams=null, $bindTypes=null)
{
$result = parent::query($sqlStatement, $bindParams, $bindTypes);
$result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
return $result;
}
}