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

          **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)