[英]ZF2 TableGateway query returning empty resultset, Adapter query works
I've moved an application between servers. 我已经在服务器之间移动了一个应用程序。
From: 从:
To: 至:
Below the TableGateway
selectWith()
returns an empty resultset but when the same $select
is queried via Adapter->query()
it works as expected. 在TableGateway
之下, selectWith()
返回一个空结果集,但是当通过Adapter->query()
查询相同的$select
时,它将按预期工作。 It worked fine on the previous server. 在以前的服务器上运行正常。 The TableGateway
selectWith()
is the original code and needs to work. TableGateway
selectWith()
是原始代码,需要工作。 Apart from the version numbers above, nothing else has changed. 除了上面的版本号,其他都没有改变。
$select = $this->tableGateway->getSql()->select()->where(array(
'col1 = ?' => $input
));
// via selectWith
$resultSet = $this->tableGateway->selectWith($select);
// via query
$selectString = $this->tableGateway->getSql()->buildSqlString($select);
$adapter = $this->tableGateway->getAdapter();
$results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
// works
var_dump($results->current());
// doesn't work
var_dump($resultSet->current());
Update: 更新:
$select = $this->tableGateway->getSql()->select()->where(array(
'col1 = \''.$input.'\''
));
The above code works. 上面的代码有效。 So the problem must be with the way TableGateway Select placeholder and replacements. 因此,问题必须出在TableGateway选择占位符和替换项的方式上。 I've tried all the variations in the docs and they should work but don't. 我已经尝试了文档中的所有变体,但它们应该可以工作,但不能。
Further update: 进一步更新:
Obviously one of these uses sqlsrv_query
and the other uses sqlsrv_execute
. 显然,其中一个使用sqlsrv_query
,另一个使用sqlsrv_execute
。 I've been through the library and there must be a problem with the way it binds params to sqlsrv_prepare
but I haven't got to the bottom of it yet. 我已经遍历该库,并且它将参数绑定到sqlsrv_prepare
的方式肯定存在问题,但是我还没有sqlsrv_prepare
了解它。 sqlsrv_prepare
requires pass by reference. sqlsrv_prepare
需要通过引用传递。 I suspect the bug is an incompability with this breaking change between 5.6 and 7. 我怀疑该错误与5.6和7之间的重大变化是不兼容的。
The issue here is that ZF2 is not compatible with PHP > 5.6. 这里的问题是ZF2与PHP> 5.6不兼容。 In this instance the API for sqlsrv has been made stricter due to deprecation of "call-time pass-by-reference". 在这种情况下,由于不赞成使用“调用时传递引用”,因此使sqlsrv的API更加严格。 The solution is to stick with PHP 5.6 or refactor a large amount of the code. 解决方案是坚持使用PHP 5.6或重构大量代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.