Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Property not found - Am I missing something?
  • I'm trying to build models using ORM in FuelPHP, never used ORM before, so not sure of certain aspects. I have a table Project and a table Revision. Now, projects have multiple revisions, revision has only one project. However, I have an additional link between Project and Revision where I always keep the ID of the latest revision in my Project table. My tables look like this:
    products
    - id
    - latest_revision_id
    - ...
    
    revisions
    - id
    - project_id
    - ...
    

    The project model:
    class Model_Project extends Orm\Model
    {
    
        protected static $_belongs_to = array(
            'latest_revision' => array(
                'key_from' => 'latest_revision_id'
            ),
        );
    
        protected static $_has_many = array(
        'revisions',
        );
    
    ...
    
    }
    

    The revision model:
    class Model_Revision extends \Orm\Model
    {
    
        protected static $_belongs_to = array(
            'project',
        );
    
        protected static $_has_one = array(
            'project' => array(
                'key_to' => 'latest_revision_id',
            ),
        );
    
    }
    

    However, when I try to access: $project->latest_revision, it gives me an OutOfBoundException: OutOfBoundsException [ Error ]: Property "latest_revision_id" not found for Model_Project exception. Am I missing something? Thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!