美文网首页
ThinkPhp5 模型查询结果转化成数组

ThinkPhp5 模型查询结果转化成数组

作者: zhaoxiaohui520 | 来源:发表于2020-04-25 11:30 被阅读0次
ThinkPhp5 模型查询结果转化成数组
$user = USER::get(1);
//此时$user是object
$user = USER::get(1)->toarray();
//此时$user是array 一位数字组
$user = USERR::where('id',1)->select();
//此时$user是二维数组,第二维是object
$user = USERR::where('id',1)->select();
$user = collection($user)->toarray();
//此时$user就是二维数组了 collection 是thinkphp助手函数
//如果$user是空,collection($user)返回空数组

相关文章

网友评论

      本文标题:ThinkPhp5 模型查询结果转化成数组

      本文链接:https://www.haomeiwen.com/subject/nzbhwhtx.html