CodeIgniter Forums
DB error after CI 1.6.1 upgrade - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: DB error after CI 1.6.1 upgrade (/showthread.php?tid=6122)



DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Lockzi[/eluser]
Hello,

after upgrading to CodeIgniter 1.6.1, I keep on getting this error message

Quote:Fatal error: Call to a member function order_by() on a non-object in C:\wamp\www\system\application\models\ss_model.php on line 32

Here's my model code (little stripped)

Code:
class Ss_model extends Model
{
    
    function Ss_model()
    {
        // Overloading with constructor
        parent::Model();
    }

    function retriveRecent($offset, $limit = 30)
    {
        
        $this->db->order_by("date", "desc");  
        
        if (is_numeric($offset))
            $this->db->offset($offset);
        if (is_numeric($limit))
            $this->db->limit($limit);
        
        if (!is_numeric($limit) && !is_numeric($offset))
        {
            $count = $this->db->get('news');
            return $count->result_array();
        }
        else
        {
            return $this->db->get('news');
        }
    }
}


Line 32 is this one
Code:
$this->db->order_by("date", "desc");


I have activated activerecord in the database.php file.

Cheers, Lockzi


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Lockzi[/eluser]
Fixed.


Apparently you have to load the database library on your own now. Or maybe I've always have had to, but overwrote my autoload.php file.


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Phil Sturgeon[/eluser]
1.6.1? When did that come out?

Anyway, yea you have to autoload the database class if you want to use it. Be careful on upgrades not to overwrite your config files. Dont copy that folder over and check the upgrade guide for what changes should be made there.


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Lockzi[/eluser]
[quote author="thepyromaniac" date="1203096513"]1.6.1? When did that come out?

Anyway, yea you have to autoload the database class if you want to use it. Be careful on upgrades not to overwrite your config files. Dont copy that folder over and check the upgrade guide for what changes should be made there.[/quote]

Version 1.6.1

Release Date: February 12, 2008


Yes... Silly me... Smile


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]xwero[/eluser]
[quote author="thepyromaniac" date="1203096513"]1.6.1? When did that come out?[/quote]
3 days ago Smile


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Lone[/eluser]
I so missed the release as well!


DB error after CI 1.6.1 upgrade - El Forum - 02-15-2008

[eluser]Derek Allard[/eluser]
Not much fanfare - it was mostly bug fixes, but there were some signficant additions, and the update is easy, so I'd recommend you go for it Wink If you use RSS, you can also just follow the CI news feed.