I would like to use PDO instead of the built-in database-classes. But how can I do it? I tried to do the modifications suggested in a blog post. I commented out a part of system\database\DB.php
and also added:
$DB = new PDO(
$params['dbdriver'].':host='.$params['hostname'].';dbname='.$params['database'],
$params['username'], $params['password']);
return $DB;
But now my PHP-code crashes if I do $this->load->database();
in a Controller. So how should I use PDO and execute database queries using PDO in CodeIgniter?
I have also tried to use this code in a Controller:
foreach($this->db->query('SELECT * FROM users') as $row) {
print_r($row);
}
but it didn't work.