Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

Not sure what the problem is. The limit 1 is probably to save memory usage.

0

It is okay to limit the sql statement for the existence check but it is not okay that it also affects the resultset which i want to get.

$faa = User::where("foo",'"=","faa");
if($faa->exists()) {  -> select count(*) as aggregate from "user" where "user"."foo" like 'faa' limit 1
   echo $faa[0]->name; // For whatever reason, it is just pseudo code
   foreach($faa->get() as $elem) -> `select * from "user" where "user"."foo" = 'faa' limit 1 <-- and that is not what i am expecting

   { 
      dosomething() 
   } 

As soon i check for existence he limits the sql statement to 1. If i comment out the existence check i get the whole resultset. However if i dont check for existence and there is no result returned i would get a "Trying to access a property of a non-object" exception. I dont think this should be the normal behaviour but actually that is what get deployed on the 4.2.13 patch.

IMO that feels like a bug. An existence check on a model should not modify the model.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

wPatrick wpatrick Joined 15 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.