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:
projects
- 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.
Am I missing something?
Thanks!