Welcome Guest, Not a member yet? Register   Sign In
Error using Query Builder - CI_DB_postgre_driver
#1

Morning,
I'm trying to ue the Query Builder in Codeigniter 3 but when I try run the CI show the error below (Line in red):

Fatal error: Call to undefined method CI_DB_postgre_driver::get() in /var/www/store/application/models/Category_model.php on line 33
A PHP Error was encountered
Severity: Error
Message: Call to undefined method CI_DB_postgre_driver::get()
Filename: models/Category_model.php
Line Number: 33
Backtrace:

Model


$this->db->select('*');
$this->db->from('products')

$query = $this->db->get();
return $query;


Obs.: My database file config (database.php) is set with:
$query_builder = TRUE;
Reply
#2

Did you load the database?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-01-2016, 01:49 PM)InsiteFX Wrote: Did you load the database?

Yes, I am load database in autoload file.

I was hoping that show me the result.

When I change the code and no use query builder its work. Follow the code bellow:


$sql = "select * from category";
return $this->db->query($sql)->result();
Reply
#4

(06-01-2016, 01:22 PM)wellerson2004 Wrote: $this->db->select('*');
$this->db->from('products')
$query = $this->db->get();
return $query;

Not sure if it just your editing to simplify but you are missing a semi-colon.

PHP Code:
$this->db->select('*'); // not needed as this is the default
$this->db->from('products'// missing semi-colon
$query $this->db->get();
return 
$query// you should be returning an array (I presume) 

Try this and see if it works

PHP Code:
$results FALSE;
$query $this->db->get('products');
if (
$query->num_rows() > 0)
{
 
    $results $query->result_array();
}
return 
$results

Hope it helps,

Paul.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB