如何在 Laravel 3 中将原始查询的结果集作为数组而不是对象进行检索《拉拉维尔3》的原始答案对于拉拉维尔 ~4
默认情况下,Laravel 的原始查询方法将结果作为 stdClass 对象的数组返回:
Array
(
[0] => stdClass Object
(
[id] => 1
[username] => admin
[password] => admin123
[email] => admin@admin.com
[created_at] => 2012-12-06 18:57:19
[updated_at] => 2012-12-06 00:00:00
)
[1] => stdClass Object
(
[id] => 2
[username] => userna
[password] => user
[email] => user@gmail.com
[created_at] => 2012-12-06 00:00:00
[updated_at] => 2012-12-05 00:00:00
)
)
问题是如何让Laravel返回数组的数组:
Array
(
[0] => Array
(
[id] => 1
[username] => admin
[password] => admin123
[email] => admin@admin.com
[created_at] => 2012-12-06 18:57:19
[updated_at] => 2012-12-06 00:00:00
)
[1] => Array
(
[id] => 2
[username] => userna
[password] => user
[email] => user@gmail.com
[created_at] => 2012-12-06 00:00:00
[updated_at] => 2012-12-05 00:00:00
)
)