tp5將查詢數據返回為對象轉為數組


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();

  

參考tp5官方網站論壇:http://www.thinkphp.cn/topic/47321.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM