<?php namespace app\controllers; use Yii; use yii\filters\AccessControl; use yii\web\Controller; use yii\filters\VerbFilter; use app\models\LoginForm; use app\models\ContactForm; use yii\web\Response; /** * 获取店铺列表 */ class ShopController extends Controller { public function actionShop() { $data = (new \yii\db\Query()) /*->select(['id','email'])*/ ->from('wd_b_shop') ->limit(10) ->all(); Yii::$app->response->format=Response::FORMAT_JSON;//在返回值之前加一句,设置返回格式是JSON return ['code'=>false,'message'=>$data]; } } ?>
完美解决