查询数据返回为对象转为数组

浏览:9202 发布日期:2017/03/31 分类:ThinkPHP5专区 关键字: thinkphp5 对象 数组 转换 数据 查询
use think\Model;
collection()->toArray();
$result = collection(model("Menu")->order("listorder asc,id asc")->select())->toArray();


或是在模型里写
namespace app\admin\model;

class Menu extends \think\Model
{
protected $resultSetType = 'collection';
}

控制器
$result = model("Menu")->order("listorder asc,id asc")->select()->toArray();
最佳答案
评论( 相关
后面还有条评论,点击查看>>