Currently I only have 2 users as I'm testing; My User
model doesn't allow calling the first()
method on queries with whereIn()
.
I'm wondering if the whereIn()
method call on a big user table using an array variable of ids of users will continue comparing a value after already finding it?
My code :
$users = User::whereIn('id',$table_of_ids)->remember(2)->get();
I get an error thrown when I use the first()
method like so:
$users = User::whereIn('id',$table_of_ids)->remember(2)->first();
I'm not sure what it does under the hood, my second question is: is there a method equivalent to combining whereIn()
and remember()
and first()
in one way or another?
update
my User model :
`protected $table = 'users';
protected $hidden = array('password', 'remember_token');
protected $fillable = array(
'field1','field2',...);
public static $rules = array(
'field1'=>'required|email|max:254|unique:users',
'field2'=>'required|alpha_num|max:35|unique:users',
...
);
I do not have any relationships in my project, i do all queries manually, and he's my error screenshot :
The query fetch only id's i'm wondering what sql query does eloquent generate at first to see if the get() method on whereIn is optimized..