yii2方法

获取当前域名            $server = \yii::$app->request->hostInfo;
获取当前模块名称        $module = \yii::$app->controller->module->id;
获取当前控制器名称        $controller = \yii::$app->controller->id;

获取当前方法名称        $method = \yii::$app->controller->action->id;


控制器中跳转    return $this->redirect('index.php?r=logistics-auth/login');

使用gii生成控制器和模型文件http://域名/index.php?r=gii


yii事务

开始事务: $tran = \yii::$app->db->beginTransaction();
失败回滚: $tran->rollBack();

成功提交: $tran->commit();

js数组转json:JSON.stringify( arr );

json字符串转数组:JSON.parse( jsonStr );

猜你喜欢

转载自blog.csdn.net/m0_37971044/article/details/79584876