2010-06-11 60 views
3

我的問題是,我可以給條件[ 'BookTitleMaster.id' => $xtitid, ]像下面CakePHP的包含 - 條件

$bbookinfs = $this->BookStockin->BookIssue->find('all', array(
    'conditions' => array('return_status' => 2), 
    'contain' => array(
     'BookStockin' => array(
      'BookTitleMaster' => array(
       'BookTitleMaster.id' => $xtitid, 
       'fields' => array('id','title','sub_title','book_material_type_id','book_author_id','course_detail_id','isbn_no','book_publisher_id','pub_year','pub_place','desc','no_pages','volume'), 
       'BookMaterialType' => array('name'), 
       'CourseDetail' => array('name'), 
       'BookPublisher' => array('name'), 
       'BookAuthor' => array('name')  
      ) 
     ) 
    ) 
)); 
+0

請發表您的代碼和代碼正確的縮進下一次。 – ThiefMaster 2010-06-11 11:47:10

回答

5

我相信你錯過的是:

'conditions' => array('BookTitleMaster.id' => $xtitid), 

所以,你的最終代碼應該是:

$bbookinfs = $this->BookStockin->BookIssue->find('all', array(
'conditions' => array('return_status' => 2), 
'contain' => array(
    'BookStockin' => array(
     'BookTitleMaster' => array(
      'conditions' => array('BookTitleMaster.id' => $xtitid), 
      'fields' => array('id','title','sub_title','book_material_type_id','book_author_id','course_detail_id','isbn_no','book_publisher_id','pub_year','pub_place','desc','no_pages','volume'), 
      'BookMaterialType' => array('name'), 
      'CourseDetail' => array('name'), 
      'BookPublisher' => array('name'), 
      'BookAuthor' => array('name')  
     ) 
    ) 
) 

));

HTH

0

它不應該是:

'conditions' => array('BookTitleMaster.id' => $xtitid), 
+0

你從哪裏得到? – Neal 2011-05-17 16:20:15

+0

技術上這個答案確實有幫助,只是沒有幫助它需要去哪裏 – Pooshonk 2014-08-05 15:08:20