i've tested Idiorm and Paris library and i found a strange behaviour when i use association with custom foreign_key This is the code
Class User extends Model{
public static $_table = 'User';
public static $_id_column = 'UserId';
/*
* Associations
*/
public function department() {
return $this->has_one('Department','DepartmentId');
}
} Class Department extends Model{
public static $_table = 'Department';
public static $_id_column = 'DepartmentID';
/*
* Association
*/
public function user() {
return $this->belongs_to('User','UserID');
}
} Custom foreign key is mandatory because the database schema doesn't modifiable. the result on query log test: $department= Model::factory('Department')->find_one(23); $user = $department->user()->find_many(); is: SELECT * FROM User
WHERE UserId
= '' LIMIT 1 why?
strong text sorry, my mistake in order of relation i configure in a wrong way has_one and belongs_to the correct code invert the relation