Welcome Guest, Not a member yet? Register   Sign In
Call to undefined method CI_DB_mysql_driver::row()
#1

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

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

[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
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB