cakephp包含 - 条件

时间:2010-06-11 11:42:42

标签: cakephp cakephp-1.3

我的问题是,我可以给出条件[ 'BookTitleMaster.id' => $xtitid, ],如下所示

$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')       
            )
        )
    )
));

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

不应该是:

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