CodeIgniter Forums

Full Version: Call to undefined method CI_DB_mysql_driver::row()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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...

El Forum

[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().

El Forum

[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

El Forum

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