나는 FilesController에 있는데 그 명령이 현재 사용자에게 속한 조건을 기반으로 파일을 가져 오려고합니다.CakePHP - 어떻게 조인 된 테이블의 테이블에 가입합니까?
FilesController
// Check the file exists and that it belongs to the user
$this->File->find('first', array(
'conditions' => array(
'File.id' => $id,
'Order.Customer.id' => $this->Auth->user('id')
),
'recursive' => 2
));
그때 files
위에 orders
에 가입 왼쪽에있는 SQL을 얻으려고 노력하고있어
Unknown column 'Order.Customer.id' in 'where clause'
케이크 SQL 오류 orders
에 customers
가입 왼쪽,하지만 난 전에 고객 테이블에 참여하는 방법을 알아낼 수는 없지만, 전에 해봤 다. 나는 조건으로 생각할 수있는 모든 것을 시도했고, contains
을 사용했다. 여기
고객 모델
class Customer extends AppModel {
public $hasMany = array('Order');
}
주문 모델
class Order extends AppModel {
public $belongsTo = array('Customer');
public $hasMany = array('File');
}
파일 모델
class File extends AppModel {
public $belongsTo = array('Order');
}
예제가 있습니까? 나는 '포함하다'와 함께 일할 수있는 어떤 것도 얻을 수 없었다. – BadHorsie