Subject: Problem with retrieving defined relationships
Hi,
I am having some troubles with relationships. For example, I have two tables, product_types and products, and the following Product_type model:
class Product_type extends ActiveRecord\Model { static $has_many = array(array("products"));}
When I do this:
$object = Product_type::find(1); print_r($object);
I get this:
Product_type Object( [errors] => [attributes:ActiveRecord\Model:private] => Array ( [id] => 1 [name] => mp3 )
[__dirty:ActiveRecord\Model:private] => Array ( )
[__readonly:ActiveRecord\Model:private] => [__relationships:ActiveRecord\Model:private] => Array ( )
[__new_record:ActiveRecord\Model:private] => )
Note that the __relationships array is empty. Also retrieving the table relationship by
$table = new ActiveRecord\Table("Product_type"); print_r($table->get_relationship('products'));
does not show anythingWhat am I doing wrong?
Ah, ok. These arrays are not used to store the relationship definitions, but the related items themselve! Problem solved.
(1-1/1)
June 27 2010
May 8, 2013
Subject: Problem with retrieving defined relationships
Hi,
I am having some troubles with relationships. For example, I have two tables, product_types and products, and the following Product_type model:
When I do this:
I get this:
Note that the __relationships array is empty. Also retrieving the table relationship by
does not show anything
What am I doing wrong?