Joost Berculo Tue May 21 13:16:50 -0400 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:

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 anything
What am I doing wrong?


Joost Berculo Tue May 21 16:22:58 -0400 2013

Ah, ok. These arrays are not used to store the relationship definitions, but the related items themselve! Problem solved.

(1-1/1)