从数据库中获取不完整的数据,雄辩的Laravel

时间:2016-05-31 09:14:44

标签: php laravel laravel-5 eloquent

我面对来自雄辩查询的非常奇怪的回应。如果数据集很少,它可以正常工作,但如果有大量数据,则显示垃圾。

我没有看到这种类型的错误,我很困惑,我应该问什么。

这是我的代码:

$title = Input::get('title');
$movie = $this->where('name', 'like', $title.'%')->get(['id', 'poster', 'name', 'release_date']);
echo "<pre>";
dd($movie->toArray());

我得到的结果(如果有大量数据)

array:2847 [
  0 => array:4 [
    "id" => 12
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "The Arrival of a Train"
    "release_date" => "1896-01-01"
  ]
  1 => array:4 [
    "id" => 13
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "The Photographical Congress Arrives in Lyon"
    "release_date" => "1895-06-12"
  ]
  2 => array:4 [
    "id" => 14
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "Tables Turned on the Gardener"
    "release_date" => "1970-01-01"
  ]
  .
  .
  .
  .
  623 => array:4 [
    "id" => 2206
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "The Outlaw Deputy"
    "release_date" => "1911-11-04"
  ]
  624 => array:4 [
    "id" => 2212
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "The Passions of an Egyptian Princess"
    "release_date" => "1970-01-01"
  ]
  625 => array:4 [ …4]
  626 => array:4 [ …4]
  627 => array:4 [ …4]
  628 => array:4 [ …4]
  629 => array:4 [ …4]
  630 => array:4 [ …4]
  631 => array:4 [ …4]
  632 => array:4 [ …4]
  633 => array:4 [ …4] // I don't know why I am getting this result set

当数据集很少时,我得到了正确的结果

array:4 [
  0 => array:4 [
    "id" => 4538
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "Titanic: Echoes of Titanic"
    "release_date" => "1970-01-01"
  ]
  1 => array:4 [
    "id" => 4540
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "Titanic: End of an Era"
    "release_date" => "1970-01-01"
  ]
  2 => array:4 [
    "id" => 4545
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "Titanic: The Mystery & the Legacy"
    "release_date" => "1970-01-01"
  ]
  3 => array:4 [
    "id" => 4548
    "poster" => "http://ratersapp.com/posters/no-poster.jpg"
    "name" => "Titanic: Titanic Remembered"
    "release_date" => "1970-01-01"
  ]
]

有人可以帮我解决这个问题。

谢谢,

1 个答案:

答案 0 :(得分:1)

当您使用 dd()时,用于转储数据到您的浏览器的转储程序实现仅按顺序转储有限的数据集保持响应大小合理。达到此限制后转储的项目不再展开。

此限制设置为 2500 ,您的所有记录都包含4个字段,这就是为什么您只能 625 行扩展(4分之2500= 625)