webman-admin 插件中使用 thinkorm 在插件下的配置文件未生效

轻风细雨

问题描述

webman-admin 插件中使用 thinkorm 查询时默认获取的是根目录下config/thinkorm.php配置文件
在插件下我也配置了该文件,但在查询时根目录下的配置文件优先级貌似更高,请问是有写法的问题吗?该如何修正才能使Db操作时,默认获取插件下的配置文件

程序代码

插件下的配置文件代码

截图

根目录下配置文件

截图

查询测试代码

截图

报错信息

think\db\exception\PDOException: SQLSTATE[HY000] [1049] Unknown database 'test' in C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php:797
Stack trace:
#0 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\connector\Mysql.php(66): think\db\PDOConnection->getPDOStatement('SHOW FULL COLUM...')
#1 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(422): think\db\connector\Mysql->getFields('`group`')
#2 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(362): think\db\PDOConnection->getTableFieldsInfo('group')
#3 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(409): think\db\PDOConnection->getSchemaInfo('group')
#4 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(493): think\db\PDOConnection->getTableInfo('group', 'type')
#5 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\concern\TableFieldInfo.php(58): think\db\PDOConnection->getFieldsType('group')
#6 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\concern\TableFieldInfo.php(81): think\db\Query->getFieldsType()
#7 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\Builder.php(333): think\db\Query->getFieldsBindType()
#8 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\Builder.php(304): think\db\Builder->buildWhere(Object(think\db\Query), Array)
#9 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\builder\Mysql.php(95): think\db\Builder->parseWhere(Object(think\db\Query), Array)
#10 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(920): think\db\builder\Mysql->select(Object(think\db\Query))
#11 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(701): think\db\PDOConnection->think\db\{closure}(Object(think\db\Query))
#12 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\PDOConnection.php(921): think\db\PDOConnection->pdoQuery(Object(think\db\Query), Object(Closure))
#13 C:\Users\Administrator\Desktop\project\php\webman\vendor\topthink\think-orm\src\db\BaseQuery.php(1156): think\db\PDOConnection->select(Object(think\db\Query))
#14 C:\Users\Administrator\Desktop\project\php\webman\plugin\tfcms\app\admin\controller\GroupController.php(18): think\db\BaseQuery->select()
#15 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\webman-framework\src\App.php(325): plugin\tfcms\app\admin\controller\GroupController->index(Object(support\Request))
#16 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\webman-framework\src\App.php(349): Webman\App::Webman\{closure}(Object(support\Request))
#17 C:\Users\Administrator\Desktop\project\php\webman\plugin\admin\api\Middleware.php(50): Webman\App::Webman\{closure}(Object(support\Request))
#18 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\webman-framework\src\App.php(341): plugin\admin\api\Middleware->process(Object(support\Request), Object(Closure))
#19 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\webman-framework\src\App.php(168): Webman\App::Webman\{closure}(Object(support\Request))
#20 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#21 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #284)
#22 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\workerman\Worker.php(1485): Workerman\Events\Select->loop()
#23 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\workerman\Worker.php(1402): Workerman\Worker::forkWorkersForWindows()
#24 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#25 C:\Users\Administrator\Desktop\project\php\webman\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#26 C:\Users\Administrator\Desktop\project\php\webman\start.php(4): support\App::run()
#27 {main}

测试环境

系统:windows
PHP版本:PHP7.4
558 1 0
1个回答

轻风细雨

问题已经解决

打印Db获取到的配置文件知道了,插件的配置和主目录的配置合并到一起了,插件中需要指定数据库标识,但是还是不知道有没有提升插件配置优先级的方法

  • 暂无评论
年代过于久远,无法发表回答
×
🔝