CodeIgniter Forums
Call to undefined method CI_DB_mysql_driver::row() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Call to undefined method CI_DB_mysql_driver::row() (/showthread.php?tid=11512)



Call to undefined method CI_DB_mysql_driver::row() - El Forum - 09-11-2008

[eluser]Bramme[/eluser]
Okay, I've probably been staring too long at my screen and I just can't see it, but what's wrong with this?

Code:
function edit($tutID = NULL) {
    if ( ! isset($tutID) OR ! is_numeric($tutID)) {
        redirect('/admin/tutorial/overview');
    }
    $this->db->where('tutId', $tutID);
    $query = $this->db->select('tutorial');
    $data['data'] = $query->row();
}
I get the error mentioned in the title...


Call to undefined method CI_DB_mysql_driver::row() - El Forum - 09-11-2008

[eluser]m4rw3r[/eluser]
You have to call get() to get the value:
Code:
function edit($tutID = NULL) {
    if ( ! isset($tutID) OR ! is_numeric($tutID)) {
        redirect('/admin/tutorial/overview');
    }
    $this->db->where('tutId', $tutID);
    $this->db->select('tutorial');
    $query = $this->db->get('tablename');
    $data['data'] = $query->row();
}
Select() only returns the db object, to enable chaining. But get() and get_where() return DB_result objects which have row().


Call to undefined method CI_DB_mysql_driver::row() - El Forum - 09-11-2008

[eluser]xwero[/eluser]
When i was looking at the code i couldn't see the problem either, i guess select feels more natural than get Smile


Call to undefined method CI_DB_mysql_driver::row() - El Forum - 09-11-2008

[eluser]Bramme[/eluser]
D'oh. How silly of me.