我正在尝试使用find语句来相应地获取内容
users(id, name, city_id)
visitors(id, user_id, visitor_id) // visitor_id also refers to users table
cities(id, name)
PHP
$visitor_data = $this->User->Visitor->find('all', array(
'conditions' => array('user_id' => 1),
'limit' => 10,
'order' => array('timestamp DESC'),
'contain' => array('VisitorDetails' => array(
'fields' => array('id', 'first_name', 'last_name', 'username', 'city_id'),
'contain' => array('City'))
)
));
我收到了错误消息:
SQL错误:1054:'字段中的未知列'VisitorDetails.contain' 列表“
我想获取访客详情城市信息
答案 0 :(得分:2)
VisitorDetails应该是单数:
'contain' => array('VisitorDetail' .....
答案 1 :(得分:2)
<?php $visitor_data = $this->User->Visitor->find('all', array(
'conditions' => array(
'user_id' => 1
),
'limit' => 10,
'order' => array(
'timestamp DESC'
),
'contain' => array(
'VisitorDetail' => array(
'fields' => array(
'id',
'first_name',
'last_name',
'username',
'city_id'
),
'contain' => array(
'City'
)
)
)
));
?>