shafiq.rst khan Tue Jan 29 02:08:16 -0500 2013
name the tables as users and topics
user foreign key as user_id
In topic model
static $belongs_to = array(
array('users', 'class_name' => 'UserRecord'),
);
In User Model
static $has_many = array(
array('topics', 'class_name' => 'TopicRecord'),
);
Stephen Patterson Tue Jan 29 10:12:56 -0500 2013
Unfortunately I need to keep the current database structure, we're applying ActiveRecord to an existng data set.
(1-2/2)
Subject: $belongs_to relationship from existing SQL structure, custom column & class names
New to active record, I've an existing DB structure & am using custom class names to avoid collision with existing classes. Already spent a few hours through the docs, forum & examples to no avail, so if anyone can help that would be most appreciated.
Summary db structure:
Table: 'user', class UserRecord, has primary key 'id'
Table: 'topic', class TopicRecord has foreign key 'user' references user(id)
What's the correct $beongs_to for the UserRecord class & what should $has_many in TopicRecord read?