CakePHP 1.3 - Unknown column in where clause

前端 未结 5 751
情话喂你
情话喂你 2021-01-18 02:02

I\'m working on an already existing cakephp 1.3 project and I needed to add a new table to the database. I have this in my controller:

    $conditions = arra         


        
5条回答
  •  走了就别回头了
    2021-01-18 02:19

    You need to link your model ShootingPlacement with "Email" with which you call it.

    class ShootingPlacement extends AppModel
    
    var $name = 'Shooting';
    
    var $hasMany= array
    (
        'Email' => array
        (
            'className' => 'Email',
            'foreignKey' => 'yourfk'
        ),
       );
    }
    

    And uses it s very powerful ContainableBehavior !

    exemple :

    $contain=array('Email'=>array('fields'=>array('id','...')));
    $conditions=array('ShootingPlacement.id'=>$yourId);
    $this->ShootingPlacement->attachBehaviros('Containable');
    $this->ShootingPlacement->find('all',$conditions);// your will retrieve yoru SHootingItem + Emails linked 
    

提交回复
热议问题