Kohana V3 return query result as object
In Kohana V3 is it possible to return result set as an array() or any method exists?
For example:
$user 开发者_开发技巧= DB::select('*')->from("users")->where('username', '=', $username);
If method is there,then it is possible to get password like
echo $user->password;
Is it possible without ORM? Please suggest.
I think the following would give you all results:
$user = DB::select('*')->from("users")->where('username', '=', $username)->as_object()->execute();
Whereas the following here, would give you the first item:
$user = DB::select('*')->from("users")->where('username', '=', $username)->as_object()->execute()->current();
Try: KO3 Database Wiki
You just need to add a ->current()
to the end of your query:
$user = DB::select('*')->from("users")->where('username', '=', $username)->execute()->current();
精彩评论