我想做一个像这样的查询
SELECT `User`.`id`, `User`.`nome`, `User`.`email`, `User`.`slug`,
`Photo`.`id`, `Photo`.`title`, `Photo`.`user_id`,
`Scheda`.`id`, `Scheda`.`user_id`, `Scheda`.`size`, `Scheda`.`weight`,
`Size`.`id`, `Size`.`value`, `Weight`.`id`, `Weight`.`value`
FROM `database`.`users` AS `User`
LEFT JOIN `database`.`photos` AS `Photo`
ON (`Photo`.`user_id` = `User`.`id`)
LEFT JOIN `database`.`schedas` AS `Scheda`
ON (`Scheda`.`user_id` = `User`.`id`)
LEFT JOIN `database`.`sizes` AS `Size`
ON (`Size`.`id` = `Scheda`.`size`)
LEFT JOIN `database`.`weights` AS `Weight`
ON (`Weight`.`id` = `Scheda`.`weight`)
WHERE `slug` = 'alessandro' LIMIT 1
如何进入控制器?
由于 的Alessandro
答案 0 :(得分:0)
解决
我为Size和Weight创建了Model,然后我在UserController中插入了代码:
$this->loadModel('Size');
$size=$this->Size->find('all', array(
'conditions' => array('Scheda.user_id = '.$data['User']['id']),
'fields'=>array('Size.value')
));
$this->set('size',$size);
唯一的问题是......为什么进入视图我必须用0调用该值?
echo $size['0']['Size']['value']
echo $size['Size']['value'] //didn't work.
的Alessandro