### 模型
*****
配置好`config/database.php`文件后
在应用中创建模型目录`application/model/`
```
<?php
namespace app\model;
use think\Model;
class Info extends Model
{
}
```
控制器中使用:
```
namespace app\home\controller;
use tian\Controller;
use app\model\Info;
class Index extends Controller
{
public function index()
{
$id = input("id");
$info = [];
if($id){
$modelInfo = new Info;
$info = $modelInfo->where("id",$id)->find();
}
$data = [
'info' => $info,
];
$this->fetch("index", $data);
}
}
```
也可以在公共模块目录中创建模型目录`application/common/model/`
```
<?php
namespace app\common\model;
use think\Model;
class Info extends Model
{
}
```
也可以在应用模块中创建模型目录`application/home/model/`
```
<?php
namespace app\home\model;
use think\Model;
class Info extends Model
{
}
```