php - Laravel find() query doesn't bind any data -
Use of LARVAL 4.0
This is to find my call:
User: Find (2) - & gt; The first ()
and the result is getQueryLog ()
:
[query] = & gt; * Select range from users * 1 [binding] = & gt; Array ()
I expected it to be a where =?
.
't
Thanks for the help.
It is sufficient to use:
$ user = User :: Search (2);
This will give you the user with the primary key 2
.
You do not have to search for with
first
- there is only one user with the given primary key, so that the user automatically gets the attribute and this In case you do not need to use first
if you want to get the user in such a way, you can use first:
$ user = User :: where ('id', '2') - & gt; First ();
equals the above code:
$ user = user :: find (2);
(assuming id
is the primary key)
Comments
Post a Comment