I can't fetch result using PDO driver in Codeigniter3.
Configured pdo driver in config/database.php as below
$db['default'] = array(
'dsn' => 'mysql:host=localhost;dbname=my_db',
'hostname' => '',
'username' => 'root',
'password' => 'root',
...
$autoload['libraries'] = array('database','session');
...
$query =
"SELECT * FROM abc LIMIT 10";
var_dump($this->db);
$q=$this->db->query($query)->fetchAll();
but results in
An uncaught Exception was encountered
Type: Error
Message: Call to undefined method CI_DB_pdo_result::fetchAll()
But if i try by creating PDO Object directly i can fetch data
$dsn="mysql:host=localhost;dbname=my_db";
$username = "root";
$password = "root";
try
{
$db = new PDO($dsn,$username,$password);
echo "connected";
$query =
"SELECT * FROM abc ";
$q=$db->query($query)->fetchAll();
echo "<pre>";
var_dump($q);
echo "</pre>";
}
catch (PDOException $e)
{
}
What should i do to fix pdo configured in application/database.php?