Subject: [RESOLVED] Help with Association Config -- Donation to your coffee fund for your help! :D
MySQL DB 5.1.52Latest Zend ServerPHP 5.3.x
TABLES -------------------- orgs -------------------- org_id orgname ... -------------------- -------------------- orgs_users -------------------- orgs_users_id org_id user_id ... -------------------- -------------------- users -------------------- user_id username ... -------------------- MODELS class Orgs extends ActiveRecord\Model { static $table_name = 'orgs'; static $primary_key = 'org_id'; static $has_many = array( array( 'orgs_users', 'class_name' => 'OrgsUsers', 'primary_key' => 'org_id', 'foreign_key' => 'org_id', ), array( 'users', 'class_name' => 'Users', 'through' => 'orgs_users', 'foreign_key' => 'user_id', 'primary_key' => 'user_id', ) ); } class OrgsUsers extends ActiveRecord\Model { static $table_name = 'orgs_users'; static $primary_key = 'orgs_users_id'; static $belongs_to = array( array( 'orgs', 'class_name' => 'Orgs', 'primary_key' => 'org_id', 'foreign_key' => 'org_id', ), array( 'users', 'class_name' => 'Users', 'primary_key' => 'user_id', 'foreign_key' => 'user_id', ) ); } class Users extends ActiveRecord\Model { static $table_name = 'users'; static $primary_key = 'user_id'; static $has_many = array( array( 'orgs_users', 'class_name' => 'OrgsUsers', 'primary_key' => 'user_id', 'foreign_key' => 'user_id', ), array( 'orgs', 'class_name' => 'Orgs', 'through' => 'orgs_users', 'primary_key' => 'org_id', 'foreign_key' => 'org_id', ), ); }
This just returns NULL
$orgs = new Orgs; $org = $orgs->first()->users;
Any help would be appreciated and followed up by a nice donation to your coffee fund! :D
RESOLUTION: My problem was in how I was naming the classes. Watch your class names (singular and plural) and follow the examples carefully. :D
thank you for solving your own problem :P
(1-2/2)
June 27 2010
April 16, 2013
Subject: [RESOLVED] Help with Association Config -- Donation to your coffee fund for your help! :D
MySQL DB 5.1.52
Latest Zend Server
PHP 5.3.x
This just returns NULL
Any help would be appreciated and followed up by a nice donation to your coffee fund! :D