Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
OutOfBoundsException [ Error ]: Property "" not found for
cargi
June 2012
Hi there, I'm trying to use the ORM to create a relationship between two tables. The database structure is pretty rubbish, and i'm unable to change any tables names etc. This is the error message I get: OutOfBoundsException [ Error ]: Property "" not found for Model_Categories_Description. My two models look like this: <?php
// category.php
class Model_Category extends \Orm\Model
{ protected static $_table_name = 'categories'; protected static $_primary_key = array('categories_id'); protected static $_properties = array(
'categories_id',
'categories_image',
'parent_id',
'sort_order',
'active',
'date_added',
'last_modified'
); protected static $_observers = array(
'Orm\Observer_CreatedAt' => array(
'events' => array('before_insert'),
'mysql_timestamp' => false,
'property' => 'date_added',
),
'Orm\Observer_UpdatedAt' => array(
'events' => array('before_save'),
'mysql_timestamp' => false,
'property' => 'last_modified',
),
); protected static $_has_one = array('categories_description' => array(
'model_to' => 'Model_Categories_Description',
'key_from' => 'categories_id',
'key_to' => 'categories_id',
)); } <?php
// categories/description.php class Model_Categories_Description extends \Orm\Model
{ protected static $_table_name = 'categories_description'; protected static $_primary_key = 'categories_id'; protected static $_properties = array(
'categories_id',
'language_id',
'categories_name',
'created_at',
'updated_at'
); protected static $_observers = array(
'Orm\Observer_CreatedAt' => array(
'events' => array('before_insert'),
'mysql_timestamp' => false,
),
'Orm\Observer_UpdatedAt' => array(
'events' => array('before_save'),
'mysql_timestamp' => false,
),
);
protected static $_belongs_to = array('category' => array(
'model_to' => 'Model_Category',
'key_from' => 'categories_id',
'key_to' => 'categories_id',
));
} The raw sql that fuel produces works perfectly when manually ran using phpmyadmin, but if I use:
$categories = Model_Category::find('all', array('related' => array('categories_description')));
I get that error mentioned above. Any ideas on how I go about fixing this? Thanks, Andy
ndboost
June 2012
Typically this is caused by the description column not being defined either in the model or in the view and its looking for it.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
ndboost
June 2012