How can I use DB::select() result as object in my views?
题
So this is working:
DB::select()->from('images')->execute()->as_array();
But I don't like arrays in my views (2 extra letters) I want to use the object. How can I do that?
DB::select()->from('images')->as_object()->execute();
This is giving an error.
解决方案
Aside from my comment on the original question, any query that's executed will return a Database_Result
object that can be foreached and should return stdClass objects for each row.
其他提示
You can use:
DB::select()->from('images')->as_object()->execute()->as_array();
不隶属于 StackOverflow