[英]Laravel 5: Eloquent select + with returns error 502 on nginx/apache
I have the following request: 我有以下要求:
$orders = OrderHeader
->with('status')
->select('id')
->get();
And it returns 502 Bad gateway on nginx+php-fpm and ERR_EMPTY_RESPONSE on apache2. 并在nginx + php-fpm上返回502 Bad网关,在apache2上返回ERR_EMPTY_RESPONSE。
If I remove either 'with' or 'select' everything works good. 如果删除“ with”或“ select”,则一切正常。
I've already performed the regular operations such as restarting nginx and php-fpm, reinstalling the php-fpm, changing some fastcgi parameters in nginx config - all these actions didn't help. 我已经执行了常规操作,例如重启nginx和php-fpm,重新安装php-fpm,更改nginx config中的一些fastcgi参数-所有这些操作都没有帮助。
The nginx error log shows '104 Connection reset by peer' and there's nothing in php log. Nginx错误日志显示“ 104对等重置连接”,php日志中没有任何内容。
Any ideas? 有任何想法吗?
Seems that what you really want is this: 看来您真正想要的是:
$orders = OrderHeader->with('status')->lists('id');
No need to try to select the column off of the table. 无需尝试从表格中选择该列。 If for some reason you need more control, then use a
closure
to filter the query accordingly: 如果出于某些原因需要更多控制,请使用
closure
来相应地过滤查询:
$orders = OrderHeader->with(['status' => function($query){
return $query->select('id');
}])->get();
This should resolve your issue. 这样可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.