[TOC]
# 模型
模型是存放models目錄中的,命名規則的話一般是首字母大寫,而model層一般繼承2個類
一個是\yii\db\ActiveRecord
一個是\yii\base\Model
區別是ActiveRecord集成了很多查詢函數,需要tableName進行關聯
# gii
用gii創建模塊
創建好了后,我們用gii創建的模塊的id
在gii注冊下
~~~
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '0.0.0.0']
];
//配置下
$config['modules']['admin'] = [
'class' => 'app\modules\admin',
];
}
~~~
url
~~~
http://yii2.top/index.php?r=admin/default/index
~~~
創建好了要在web.php中配置
gii頁面有
類似
~~~
'modules' => [
'v1' => [
'class' => 'app\modules\v1\Module',
],
],
~~~
- 目錄
- 配置
- 簡介
- 別名
- gii
- 配置項
- 模型
- 簡介
- 增刪改查
- AR和model
- 模型事件
- 場景
- query查詢
- 增刪改
- AR查詢器
- 模型關系定義
- AR模型連表查詢
- fields
- where拼接
- 模塊
- 創建模塊
- 控制器
- 表單
- 跳轉
- 響應
- 驗證器
- Action
- 組件
- url
- 分頁
- 驗證碼
- 緩存
- 文件上傳
- 預啟動組件
- 事件
- 自定義組件
- redis
- 日志
- 行為
- cookie和session
- 基礎知識
- 創建一個類
- 配置一個類
- object基類
- component組件類特性
- phpstorm無法更改php等級
- url地址美化
- 過濾器
- 請求處理
- 請求組件
- 響應組件
- header
- 用戶登錄
- 實現IdentityInterface接口
- 登錄
- 自動檢測登錄
- 獲取用戶信息
- 訪問行為追蹤
- phpstorm+postman斷點調試