setTableName('self_reference'); $this->hasColumn('id', 'integer', 11, array('primary' => true, 'autoincrement' => true)); $this->hasColumn('name', 'string', 255); $this->hasColumn('user_id1', 'integer', 11); $this->hasColumn('user_id2', 'integer', 11); $this->hasColumn('parent_self_reference_id', 'integer', 11); $this->hasColumn('parent_self_reference_id2', 'integer', 11); } public function setUp() { $this->hasOne('User as User1', array('local' => 'user_id1', 'foreign' => 'id')); $this->hasOne('User as User2', array('local' => 'user_id2', 'foreign' => 'id')); $this->hasOne('SelfReference as SelfReference1', array('local' => 'parent_self_reference_id', 'foreign' => 'id')); $this->hasOne('SelfReference as SelfReference2', array('local' => 'parent_self_reference_id2', 'foreign' => 'id')); $this->hasMany('SelfReference as SelfReferences1', array('local' => 'id', 'foreign' => 'parent_self_reference_id')); $this->hasMany('SelfReference as SelfReferences2', array('local' => 'id', 'foreign' => 'parent_self_reference_id2')); } }