yii 3.0 还在进行当中... 1.文档 https://blog.csdn.net/william_n/article/details/89738688 // 编码规范 https://www.yiichina.com/doc/guide/2.0 // Yii 2.0 权威指南 https://www.yiichina.com/doc/api/2.0 // Yii Framework 2.0 API 文档 http://www.yiibook.com/pc/index.html // Yii2框架从入门到精通 -- 51CTO学院 刘昆著 https://www.yiiframework.com/doc/guide/2.0/en // The Definitive Guide to Yii 2.0 [Yii 2.0 权威指南] https://www.yiiframework.com/doc/api/2.0 // Yii Framework 2.0 API Documentation 2.学习/实践 2.1 安装 https://www.yiichina.com/download 推荐使用composer方式 安装基本的应用程序模板,运行下面的命令: php composer.phar create-project yiisoft/yii2-app-basic basic 遵循 权威指南中的介绍 是开始使用基本应用程序模板的最佳方法。 安装高级的应用程序模板,运行下面的命令: php composer.phar create-project yiisoft/yii2-app-advanced advanced 成功安装~ 2.2 Yii2设计模式——Yii2中用到哪些设计模式? https://blog.csdn.net/qq_24127857/article/details/84967576 2.3 接收参数,自行封装 当传递参数值为‘’时,yii默认值并不能生效 public function getQuery($parameter, $default){ $request = Yii::$app->request; if($request->isGet){ $parameter = $request->get($parameter); } if($request->isPost){ $parameter = $request->post($parameter); } if(!$parameter){ $parameter = $default; } return $parameter; } 2.4 使用 [条件查询] $arr = HeroRunereplaces::find()->where(['uponelevelnum' => $numsIds]) ->createCommand()->getRawSql(); //->asArray()->all(); 备注: 这里如果$numsIds是数组,则会使用in, 如果是字段串或者整型 则会使用 = 2.5 Yii 2.0获取表的所有字段名称 用db组件的schema对象执行getTableSchema(表名)得出表的信息 然后再用ArrayHelper取出某一列就是整张表的所有字段集合: $table = 某某AR模型::tableName(); $tableSchema = Yii::$app->db->schema->getTableSchema($table); $fields = \yii\helpers\ArrayHelper::getColumn($tableSchema->columns, 'name', false); print_r($fields); 备注: 没有获取完整的数据表字段名【存在遗漏,原因及解决方式TBD】 2.6 Yii 2 ActiveRecord关联查询--hasOne与hasMany https://blog.csdn.net/william_n/article/details/94735596 后续补充 ... |