我如何使用DB::select()结果作为对象在我的视图


How can I use DB::select() result as object in my views?

这行得通:

DB::select()->from('images')->execute()->as_array();

但是我不喜欢数组在我的视图(2个额外的字母),我想使用对象。我该怎么做呢?

DB::select()->from('images')->as_object()->execute();

除了我对原始问题的评论之外,执行的任何查询都将返回一个可以预知的Database_Result对象,并且应该为每行返回stdClass对象。

您可以使用:

DB::select()->from('images')->as_object()->execute()->as_array();