一:控制器部分 <?php namespace app\controllers; use yii\web\Controller; class PreController extends Controller{ public $enableCsrfValidation=false; function actionIndex(){ return $this->render('index'); } function actionLogin(){ $username= \Yii::$app->r…
A id 与B a.id B id 与C b.id C id 与D c.id 查A读D数据 应用场景: order表 ordergoods表 goods表 merchant加盟商 order 与ordergoods 通过 order_id字段关联:ordergoods与goods表通过goods_id 和id关联:goods与merchant表通过merchant_id 和id关联 在order表 model里 建立关联public function getOrderGoods(){return…
model 层 联查 $con = Yii::$app->db; $re = $con->createCommand("select * from ads LEFT JOIN nav on nav.id=ads.nav_id")->queryAll(); return $re; model层 修改 $con = Yii::$app->db;return $con->createCommand("update phone set &quo…
处理请求 class TestController extends Controller { public function init() { if(!YII_ENV_DEV){ throw new ExitException(201,'can not access not in dev mode'); } } /** * */ public function actionClientip() { if(YII_ENV_DEV){ $request = Yii::$app->getRequest…