we're using codeigniter with postgresql, our following code works in MySQL type database, but in postgresql, it shows errror
Fatal error: Call to a member function result() on a non-object in /application/models/category_m.php on line 61
Our Model Code:
$this->db->select('ci_categories.cat_id, ci_categories.cat_name, COUNT(ci_albums.album_id) AS total_albums');
$this->db->from('ci_categories');
$this->db->join('ci_albums', 'ci_albums.cat_id = ci_categories.cat_id', 'left');
return $this->db->group_by('ci_categories.cat_id')->get()->result();
Set dbdriver in application/config/database.php
The error is likely due to the fact that the query (and resulting result() object) are empty. Ensure that the query actually returns at least one record before attempting to use the result() object: