support\think\Db 怎么实现join方法

我要当省长

问题描述

use support\think\Db (没有join方法);
use think\facade\Db(有join方法)

chatgpt显示 webman的thinkorm更好一点,但是我想在 support\think\Db 中使用join方法,不知道要怎么实现,有个老项目很多地方都用到了join,只能重新创建model文件来使用withjoin吗?

116 3 0
3个回答

timeless-zyg

use support\think\Model;
试试模型呗

我要当省长

同时使用think\facade\Db 和 support\think\Db 会有性能影响或者出现奇怪的bug吗

  • 暂无评论

support\think\Db 有join方法

  • 我要当省长 1天前

    感谢老哥回复,我用的是webmanV2,强行support\think\Db::table()->join()的时候会报错:

    php:8.2 webman版本:2.1 使用的tporm版本:2.1 .

    是否我这种情况 support\think\Db 和 think\facade\Db混用好一点。

    下面是 support\think\Db使用join的错误信息

    0 ***\vendor\topthink\think-orm\src\db\connector\Mysql.php(68): think\db\PDOConnection->getPDOStatement('SHOW FULL COLUM...')

    1 ***\vendor\topthink\think-orm\src\db\PDOConnection.php(439): think\db\connector\Mysql->getFields('user_table')

    2 ***\vendor\topthink\think-orm\src\db\PDOConnection.php(396): think\db\PDOConnection->getTableFieldsInfo('user_table')

    3 ***\vendor\topthink\think-orm\src\db\PDOConnection.php(361): think\db\PDOConnection->getCachedSchemaInfo('49.235.178.253_...', 'user_table', false)

    4 ***\vendor\topthink\think-orm\src\db\PDOConnection.php(425): think\db\PDOConnection->getSchemaInfo('user_table')

    5 ***\vendor\topthink\think-orm\src\db\PDOConnection.php(477): think\db\PDOConnection->getTableInfo('user_table', 'pk')

    6 ***\vendor\topthink\think-orm\src\db\Query.php(325): think\db\PDOConnection->getPk(Array)

    7 ***\vendor\topthink\think-orm\src\db\concern\WhereQuery.php(43): think\db\Query->getPk()

    8 ***\app\controller\IndexController.php(27): think\db\BaseQuery->where(Array)

  • walkor 1天前

    仔细看报错,sql是 SHOW FULL COLUM... ,和join没关系。
    尽量用 support\think\Db

  • 我要当省长 1天前

    解决了,我的问题,多谢老哥

×
🔝