eric wang Mon Jul 02 22:28:25 -0400 2012

Subject: About one-to-many association

class Employee extends ActiveRecord\Model {
static $primary_key = 'employeeid';
static $belongs_to = array(array('department'));
}

class Department extends ActiveRecord\Model {
static $primary_key = 'departmentid';
static $has_many = array(
array('employees','foreign_key' => 'departmentid')
);
}

print_r(Department::first()->employee);
// Undefined property: Department->employee

var_dump(Employee::first()->department);
// NULL

how to get association table data?