Monday, March 22, 2010

[CakePHP] use model in component or model

$a = ClassRegistry::init('a');
$options['fields'] = array('a.eventname', 'a.event_pic');
$options['joins'] = array(
    array('table' => 'soul_match_event_join',
        'alias' => 'b',
        'type' => 'INNER',
        'conditions' => array( 'a.id = b.event_id'),
    )
);

$options['conditions'] = array( 'b.uid' => $uid);
$options['order'] = array( 'a.id DESC');

$result2 = $a->find('first', $options);

if ($result2){
    $res[$this->name]['event_name'] = $result2['a']['eventname'];
    $res[$this->name]['event_pic'] = $result2['a']['event_pic'];
}

No comments: