
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 1.15 KB | hits: 8 | expires: Never
<?php
/**
* Person
*
* Application model for `Person` records.
*
* Schema: id, father_id, mother_id, first_name, last_name
*
* @author Joe Beeson <jbeeson@gmail.com>
*/
class Person extends AppModel {
/**
* "Belongs to" associations.
*
* @var array
* @access public
*/
public $belongsTo = array(
'PersonMother' => array(
'className' => 'Person',
'foreignKey' => 'mother_id'
),
'PersonFather' => array(
'className' => 'Person',
'foreignKey' => 'father_id'
)
);
/**
* "Has many" associations.
*
* @var array
* @access public
*/
public $hasMany = array(
'PersonChildren' => array(
'className' => 'Person',
/**
* Since we have [two] fields that could possibly associate us
* to our `PersonChild` records we have to override the query
* to make sure we're searching both.
*/
'finderQuery' => 'SELECT `PersonChildren`.* FROM `people` AS `PersonChildren` WHERE `PersonChildren`.`father_id` IN ({$__cakeID__$}) OR `PersonChildren`.`mother_id` IN ({$__cakeID__$})',
// Note we also need to say false to "foreignKey"
'foreignKey' => false
)
);
}