作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以连接两个不同数据库连接的表(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/
我是一名优秀的程序员,十分优秀!