<?php namespace appcontrollers; use Yii; use yiifiltersAccessControl; use yiiwebController; use yiifiltersVerbFilter; use appmodelsLoginForm; use appmodelsContactForm; use yiiwebResponse; /** * 获取店铺列表 */ class ShopController extends Controller { public function actionShop() { $data = (new yiidbQuery()) /*->select(['id','email'])*/ ->from('wd_b_shop') ->limit(10) ->all(); Yii::$app->response->format=Response::FORMAT_JSON;//在返回值之前加一句,设置返回格式是JSON return ['code'=>false,'message'=>$data]; } } ?>
完美解决