Hi…
I have a problem with a one-to-many self relationships
How to describe a model for the table:
`id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(5) unsigned DEFAULT NULL,
`name` varchar(255) NOT NULL
parent_id is nullable
I tried with the code:
/* model */
class Organization extends DataMapper {
var $table = 'organizations';
var $has_one = array(
'parent' => array(
'class' => 'organization',
'other_field' => 'organization',
'join_self_as' => 'parent'
));
var $has_many = array(
'organization' => array(
'other_field' => 'parent'
)
);
/* controller */
$org = new Organization();
$org->include_related('parent', array('name'));
$list = $org->get();
but it appears an error
Fatal error: Cannot use object of type Organization as array in Z:\htdocs\application\libraries\datamapper.php on line 2817
I tried looking in the manual, but could not find guides for it.
Thanks for helping ![]()
Note: im using CI2, Datamapper1.8.1 and HMVC.
