开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜