• 模型生成
    • 模型生成

    模型生成

    模型生成


    模型文件支持使用命令行自动生成命令;

    php index.php record -s 查找需要生成模板文件的表前缀 -p 需要去除显示的表前缀 -n 命令空间php index.php record -h 可以查看使用帮助

    生成的文件在

    runtime/model

    下,自己将文件拷贝到正确的位置并清空runtime/model 文件夹

    生成的模板文件为

    1. <?php
    2. namespace 包名;
    3. use rap\db\Record;
    4. class 表名转驼峰 extends Record{
    5. public function getTable(){
    6. return "表名";
    7. }
    8. public function getFields(){
    9. return [
    10. //字段定义
    11. 'id'=>'int',
    12. 'device'=>'string'
    13. ];
    14. }
    15. //字段
    16. public $id;
    17. public $device;
    18. }

    上一篇:多数据源   下一篇:IOC控制反转