[英]Zend Framework 2 cross database joins
Is there any real way to do a cross database join in a zf2 select statement? 有什么真正的方法可以在zf2 select语句中进行跨数据库联接? Ive been looking for a viable way to perform this without resorting to writing a full sql statement instead.
我一直在寻找一种可行的方法来执行此操作,而不必诉诸编写完整的sql语句。
Currently my query looks somewhat like this: 目前,我的查询看起来像这样:
$selectDB2 = $this->getSelect('db2.tabledb2');
$selectDB = $this->getSelect('field1');
$selectDB->join(
['tabledb2' => $selectDB2],
'tabledb1.id = tabledb2.id',
[],
$select::JOIN_LEFT. ' '. $select::JOIN_OUTER
);
After research I found that ZF2 does have issues: https://github.com/zendframework/zf2/issues/4307 经过研究,我发现ZF2确实存在问题: https : //github.com/zendframework/zf2/issues/4307
The problem is the way that zf2 escape quotes, and a solution is listed. 问题是zf2转义引号和列出解决方案的方式。 However, I was ideally after a way that would not involve having to modify the zf2 library itself, and also didnt require me to have to write one lengthy sql statement instead (as this isnt a viable option for the scope of this query).
但是,理想情况下,我希望采用一种无需修改zf2库本身的方法,并且也不需要我必须编写一个冗长的sql语句(因为这不是此查询范围的可行选择)。
Solved. 解决了。 ZF2's TableIdentifier gets around this problem very nicely.
ZF2的TableIdentifier很好地解决了这个问题。 This resolves everything very cleanly and effectively.
这样可以非常干净有效地解决所有问题。
$selectDB2 = $this->getSelect(new TableIdentifier('tabledb2', 'db2'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.