我需要将结果过滤到数组,但我收到以下通知
注意(8):数组转换为字符串[APP / Model / User.php,第199行] 注意(8):未定义的变量:数组[APP / Model / User.php,第199行]
$hotelsId = ClassRegistry::init('HotelUser')->find('all',array('fields'=>array('hotel_id'),'conditions'=>array('user_id'=>$userId)));
$ids = array();
foreach ($hotelsId as $hotel) {
$ids[] = $hotel['HotelUser']['hotel_id'];
}
$hotels = ClassRegistry::init('Hotel')->find('list',array('conditions'=>array('IN'=>array('Hotel.id'=>$ids))));
答案 0 :(得分:0)
$hotelsId = ClassRegistry::init('HotelUser')->find('list',array(
'fields'=>array('hotel_id'),
'conditions'=>array('user_id'=>$userId)));
$hotels = ClassRegistry::init('Hotel')->find('list',array(
'conditions'=>array('Hotel.id'=>$hotelsId)));
希望这会有所帮助!