Mr. Carl
Fri Jan 27 14:38:24 -0500 2012
CLOSE TOPIC
The problem was 'foreign_key' => 'email_type_id'. Because I had more then one foreign_key on my table the Model didn't know which one to choice from.
1
2 class Email extends ActiveRecord\Model
3 {
4 // A one-to-one relationship
5 static $belongs_to = array
6 (
7 array('email_type', 'class_name' => 'Email_Type',
8 'foreign_key' => 'email_type_id', 'readonly' => true)
9 );
10 // Validation of data
11 }
12
(1-1/1)
Subject: Associations of Associations
I'm unable to load data from a sub-associations from other associations. It only return null.
Model: Customer->Email(Associations)->Email_Type(Associations which doesn't load data only return null)
I'm using CodeIgniter Version 2.1, spark manager 0.0.7, php.activerecord v1.0( from this website not the spark activerecord), and XAMPP 1.7.7.
I can connect all of my model that extends ActiveRecord\Model.
Database layout:
php model code:
I tried switching class Email:static $belongs_to to $has_many however I get the following error:
Fatal error: Uncaught exception 'ActiveRecord\DatabaseException' with message '42S22, 1054, Unknown column 'email_id' in 'where clause'' in....
Second question how much information does the parent class need to load into class for the Associations to work?