# 实例模型

可以使用Yii2自带GII 工具生成模型，建议继承 `app\common\models\Model`

* 访问部署域名 +/gii ，生成 model 实例文件
* 继承 `app\common\models\Model`
* 首次生成文件建议放在 `app\common\models\other`下，详情原因参考 [Yaa项目结构](/ji-chu/xiang-mu-jie-gou.md)

在各个模块中使用实例模型时建议采取以下方式。

## 示例

以`user`模型作为示例，分别三个模块（后台、小程序、前台）需要用户数据时。

因生成`user`模型首次文件为 `app\common\models\other\User`&#x20;

可对应建立三个模块（backend、applets、frontend）在代码中分别为：

```

├── modules    
│   ├── backend
│   ├── applets
│   ├── frontend

对应中建立不同的  user 文件 如下：

├── modules    
│   ├── backend
│   │   ├── models
│   │   │  ├── User.php
│   ├── applets
│   │   ├── models
│   │   │  ├── User.php
│   ├── frontend
│   │   ├── models
│   │   │  ├── User.php

```

以上三个文件User.php 各司其职，便于管理维护。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yaa.docs.speaks.life/he-xin-gong-neng/shu-ju-biao-ge/shi-li-mo-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
