2013-04-23 4 views

답변

2

수 있습니다 !!
확인이 당신이

$table = 'table_name'; 
    $query['conditions'] = array($table.'.entity_id' => $entity_id, $table.'.is_active' => 1); 

     $query['fields'] = array('creator.first_name AS cf_name', 'creator.last_name AS cl_name', 'creator.email AS c_email', 'usr.first_name', 'usr.last_name', 
      $table.'.id AS id', $table.'.guid', $table.'.updated_date', 
      'usr.email AS email'); 

     // To do joining to get attribute with value 
     $query['joins'] = array(
      array(
        'table' => $this->user, 
        'alias' => 'usr', 
        'type' => 'INNER', 
        'conditions' => array('usr.id = '.$table.'.user_id') 
       ), 
       array(
        'table' => $this->user, 
        'alias' => 'creator', 
        'type' => 'INNER', 
        'conditions' => array('creator.id = '.$table.'.creator_id') 
       ), 
     ); 
     $query['order'] = array($table.'.updated_date' => 'DESC'); 

     // Cache implementation 
     $result = $this->find('all', $query); 
+0

주제에 대한 자세한 내용은 다음을 참조하십시오. http://bakery.cakephp.org/articles/nate/2009/01/21/quick-tip-doing-ad-hoc-joins -in-model-find – jrace

+0

@manish 쿠마 감사합니다. – Ajay

관련 문제