webman-php / console

webman console plugin
https://www.workerman.net/webman
22 stars 14 forks source link

命令生成model文件$table=null #24

Open zhonghaibin opened 1 year ago

zhonghaibin commented 1 year ago

php webman make:model 表名 这个命令生成的model文件里面定义表名 $table 变量是 null 。 我不清楚你这里为什么要定义多一个$table_val变量 ,然后做这样的判断。这是一个bug吗? 我想要的结果是有带表前缀的表名,例如:$table=mm_users Snipaste_2023-07-11_00-21-53

walkor commented 1 year ago

table 为null ORM会自动将类名转换为表名

zhonghaibin commented 1 year ago

table 为null ORM会自动将类名转换为表名

在使用上数据库上orm是没有什么问题的。只是我看到 webman的默认用的是laravel 的 Eloquent ORM。我用phpstrom里面的laravel query 插件来提取数据库字段,来提高效率。如果model没有生成表名这个插件就识别不了数据库字段,因此我要手动去维护这个表名。 Snipaste_2023-07-11_09-08-38

https://github.com/webman-php/console/assets/22255693/6c2d9907-a15b-4aeb-b614-c5f1c34e7da4

walkor commented 1 year ago

https://github.com/webman-php/console/commit/f9c56502f4e37be5af1dec642eea928d96b22b4b 试下

zhonghaibin commented 1 year ago

f9c5650 试下

这样是可以获取表名的。只是我在数据库配置文件里面配置了数据库前缀:mm_。 这里拿到的是users表名。插件要用到完整的表名:mm_users. 如果配置文件不设置前缀就没什么问题吧。如果设置前缀,生成带前缀的表名:mm_users.程序查询的时候也会有问题吧,到时会不会变成 mm_mm_users 表去查询数据库??这样就对程序有影响了吧

walkor commented 1 year ago