fastadmin和thinkphp生成其他数据库配置的菜单表命令
首先在application/config.php中添加其他数据库的配置信息,如:
return [
//...其他配置信息...
//数据库配置1
'db_config1' => [
'type' => Env::get('database.type', 'mysql'),
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'wordpress',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => 'root',
// 数据库编码默认采用utf8
'charset' => 'utf8',
],
];
然后执行创建菜单的命令
php think crud -t options -u 1 --db=db_config1
文档地址:
https://doc.fastadmin.net/doc/crud.html#toc-2
//生成fa_test表的CRUD
php think crud -t test
//生成fa_test表的CRUD且一键生成菜单
php think crud -t test -u 1
//删除fa_test表生成的CRUD
php think crud -t test -d 1
//生成fa_test表的CRUD且控制器生成在二级目录下
php think crud -t test -c mydir/test
//删除fa_test表生成的二级目录的CRUD
php think crud -t test -c mydir/test -d 1
//生成fa_test_log表的CRUD且生成对应的控制器为testlog
php think crud -t test_log -c testlog
//生成fa_test表的CRUD且对应的模型名为testmodel
php think crud -t test -m testmodel
//生成fa_test表的CRUD且生成关联模型category,外链为category_id,关联表主键为id
php think crud -t test -r category -k category_id -p id
//生成fa_test表的CRUD且所有以list或data结尾的字段都生成复选框
php think crud -t test --setcheckboxsuffix=list --setcheckboxsuffix=data
//生成fa_test表的CRUD且所有以image和img结尾的字段都生成图片上传组件
php think crud -t test --imagefield=image --imagefield=img
//关联多个表,参数传递时请按顺序依次传递,支持以下几个参数relation/relationmodel/relationforeignkey/relationprimarykey/relationfields/relationmode
php think crud -t test --relation=category --relation=admin --relationforeignkey=category_id --relationforeignkey=admin_id
//生成v_phealth_db2数据库下的fa_test表的CRUD
php think crud -t test --db=v_phealth_db2