title: ThinkPhp埋坑指南
date: 2018-10-05 17:14:01
tags: ThinkPHP


查询多列数据,返回一维数组

  1. $resSort = new ResSort();
  2. $resSortList = $resSort->where(1)->select();
  3. $sort = [];
  4. foreach ($resSortList as $resSortItem) {
  5. array_push($sort, $resSortItem['sort']);
  6. }
  7. if ($sort) {
  8. return GlobalVariable::promptData(['sort' => $sort]);
  9. }

需要使用foreach来循环建立数组,并在返回时指明数组名。