Laravel Order具有一定的价值

时间:2014-09-11 19:44:49

标签: php laravel laravel-4 eloquent

我希望我的一个关系按以下方式返回某个值的排序:

return $this->hasMany('Photo', 'owner_id')->where('active', '=', '1')->where('visible', '=', '1')->orderByRaw("(`id` = ?) DESC", array($showphoto));

但是上面的代码返回了这个:

select * from `photos` where `photos`.`owner_id` = '4' and `active` = '1' and `visible` = '1' order by (`id` = '') DESC

如何让$ showphoto变量按顺序排列?

1 个答案:

答案 0 :(得分:0)

由于您当前没有触发查询,因此无法向您显示已注入。 当你将get()方法链接到它时,它会"注入" $showphoto并执行查询。

在实际执行查询之前,我不知道有什么方法可以看到包含参数值的完整查询。