mardi 31 mai 2016

Getting incomplete data from database eloquent Laravel

I am facing very weird response from the eloquent query. It works fine if there are few set of data, but shows garbage if there is a huge set of data.

I haven't seen this type of error and I am very confused that what should I ask.

Here is my code:

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

Result I am getting (if there is a lot of data)

array:2847 [
  0 => array:4 [
    "id" => 12
    "poster" => "http://ift.tt/1sIjNGG"
    "name" => "The Arrival of a Train"
    "release_date" => "1896-01-01"
  ]
  1 => array:4 [
    "id" => 13
    "poster" => "http://ift.tt/1sIjNGG"
    "name" => "The Photographical Congress Arrives in Lyon"
    "release_date" => "1895-06-12"
  ]
  2 => array:4 [
    "id" => 14
    "poster" => "http://ift.tt/1sIjNGG"
    "name" => "Tables Turned on the Gardener"
    "release_date" => "1970-01-01"
  ]
  .
  .
  .
  .
  623 => array:4 [
    "id" => 2206
    "poster" => "http://ift.tt/1sIjNGG"
    "name" => "The Outlaw Deputy"
    "release_date" => "1911-11-04"
  ]
  624 => array:4 [
    "id" => 2212
    "poster" => "http://ift.tt/1sIjNGG"
    "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

And I am getting proper result when there are only few set of data

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

Can someone please help me to solve this.

Thanks,



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire