gpt4 book ai didi

mysql - 拉拉维尔 : join two tables of different db connections

转载 作者:行者123 更新时间:2023-11-29 16:11:02 26 4
gpt4 key购买 nike

是否可以连接两个不同数据库连接的表(mysql和oracle在两个不同的服务器中)根据条件?

我想执行此查询:

DB::connection('oracle')->table('SYSADM.PS_KS_COM_PERS_INF AS PRES')
->join(DB::connection('mysql')->table('students AS STU'),
'PRES.NATIONAL_ID','=','STU.NationalID')
->where('PRES.STUDENT_STATUS', '=', 'Record Closed')
->where('STU.Batch', '=', $value->Batch)
->get(); // or count();

我创建了每个表和连接的模型,

但我无法加入两个数据库连接的两个模型

最佳答案

Is it possible to join two tables of different db connections (mysql and oracle in two different servers)

没有。

Oracle 确实通过其 Database Gateway for ODBC 提供异构访问特征。一旦正确配置了该功能,您就可以运行这样的查询。

 DB::connection('oracle')->table('some_oracle_table')->join('some_mysql_table@mysqlConnection') ...

解释如何操纵该功能超出了 Stack Overflow 答案的范围。让您的 DBA 提供帮助。

或者,只需分别从 Oracle 连接和 MySQL 连接读取数据,然后在程序中将它们关联起来。这就是完成今年工作的方法。

关于mysql - 拉拉维尔 : join two tables of different db connections,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55260821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com