Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord for CodeIgniter: Rails-style model interactions
#88

[eluser]cayasso[/eluser]
Hi gurus, I need some help here with this, I am getting some weird behaviors and not sure why. Please let me know if I am wrong, I felt like this is possessed by some gremlins Confusedhut:

Here is what happening:

I am getting this error message bellow, somehow the $num_[...] variable seems to not been set

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$num_pages

Filename: controllers/orch.php


Text model is like this:
Code:
class Text extends ActiveRecord {

    function __construct ()
    {
        parent::ActiveRecord();
        $this->_belongs_to = array('pages');
    }
}

Page model is like this:
Code:
class Page extends ActiveRecord {

    function __construct ()
    {
        parent::ActiveRecord();
        $this->_has_many = array('texts');
    }
}

This is my controller
Code:
class ORCH extends Controller
{
    function ORCH()
    {
        parent::Controller();
        $this->load->model('page');
        $this->load->model('text');
    }
    
    function index()
    {
        $pages = $this->page->count_pages()->find_all();        
        foreach($pages as $page)
        {            
            echo '<h3>'.$page->pg_title.'</h3>';
            echo '<p>'.$page->pg_description.'</p>';
            echo '<h1>'.$page->num_pages.'</h1>';    
        }        
    }
}

I am using the development version which uses the count_ method instead of counting_, but even if I try with the stable version I get the exact same error.

Can some one help me please or else the gremlins will take me :grrr:


Messages In This Thread
ActiveRecord for CodeIgniter: Rails-style model interactions - by El Forum - 02-27-2008, 05:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB