Welcome Guest, Not a member yet? Register   Sign In
Weird query error. Please help :(.
#1

[eluser]Lazos[/eluser]
I have this query in my model. I want to extract the last row but I am getting this error:
Fatal error: Call to a member function last_row() on a non-object in D:\websites\dissertation\application\models\admin\content_model.php on line 54

Why this error is occurred? How can I solve it to get the last row?

Code:
function dbContentOrderMany ($parentid, $orderid) {
        $this->db->select('content_id');
        $this->db->from('my_content');
        $this->db->where("parent_id", $parentid);
        $this->db->order_by('item_order', 'ASC');
        $result = $query->last_row('array');
        if ($result == $orderid) {
            return true;    
        }
    }
#2

[eluser]mdowns[/eluser]
You are not setting $query.
Try this:
Code:
$query = $this->db->order_by('item_order','ASC');
$result = $query->last_row('array');
#3

[eluser]Lazos[/eluser]
I am getting this now.

Fatal error: Call to undefined method CI_DB_mysql_driver::last_row() in D:\websites\dissertation\application\models\admin\content_model.php on line 54
#4

[eluser]mdowns[/eluser]
Try a call to get like so.
Code:
$this->db->select('content_id');
        $this->db->from('my_content');
        $this->db->where("parent_id", $parentid);
        $this->db->order_by('item_order', 'ASC');
        $query = $this->db->get();
        $result = $query->last_row('array');
#5

[eluser]Lazos[/eluser]
Yes yes that was the problem. In the guide I did not understand that you have to use it too...

Thanks so much.




Theme © iAndrew 2016 - Forum software by © MyBB