【问题标题】:Eloquent error using with and select together. Segmentation fault使用 with 和 select 的 Eloquent 错误。分段故障
【发布时间】:2016-08-26 23:22:33
【问题描述】:

在一个查询生成器中执行selectwith 时,不会出现服务器错误。我刚刚收到以下消息:<domain> page isnt working. <domain> didn't send any data.

当我签入 /var/log/apache2/error.log 有一个日志:

child pid 1948 exit signal Segmentation fault (11), possible coredump in /etc/apache2

我尝试过使用here 提到的查询范围eg

$posts = Post::with(['image' => function($query){
  $query->select('id');
}])->select('id')->get();

如果我将get() 更改为toSql(),它只会输出select id from posts

我还尝试删除 select 并将列传递给 get(),但没有成功。

进一步调查:

我尝试设置 GDP 来调试 apache 核心转储,但似乎没有创建任何转储。

我已经设置了 xdebug 并跟随函数堆栈到它的 death here at function loadRelation()Eloquent\Builder.php 内。

在此之前,它调用 eagerLoadRelations(array $models) 并正确获取所有 Post 模型作为仅具有 id 属性的帖子集合,但在加载图像关系的第一次迭代时它就死了

call_user_func($constraints, $relation);

任何帮助或建议将不胜感激。

【问题讨论】:

    标签: php apache laravel eloquent lumen


    【解决方案1】:

    Segmentation fault 听起来有点奇怪,但尝试将 user_id 添加到 select 以便它可以进行连接,例如:

    $posts = Post::with(['image' => function($query){
      $query->select('id', 'user_id');
    }])->select('id')->get();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-02
      • 2018-01-19
      相关资源
      最近更新 更多