Php Zend 2.0选择查询不工作,但原始SQL中的同一查询工作
下面是我如何在Zend 2.0中创建查询的Php Zend 2.0选择查询不工作,但原始SQL中的同一查询工作,php,sql,pdo,zend-framework2,Php,Sql,Pdo,Zend Framework2,下面是我如何在Zend 2.0中创建查询的 $getVenues = $this->tableGateway->select(function (Select $select) { $select->where->greaterThanOrEqualTo('lat', (float) $lat_min); $select->where->greaterThanOrEqualTo('lng', (float) $lng_min); $se
$getVenues = $this->tableGateway->select(function (Select $select) {
$select->where->greaterThanOrEqualTo('lat', (float) $lat_min);
$select->where->greaterThanOrEqualTo('lng', (float) $lng_min);
$select->where->lessThanOrEqualTo('lat', (float) $lat_max);
$select->where->lessThanOrEqualTo('lng', (float) $lng_max);
});
正在输出以下查询:
SELECT `venues`.* FROM `venues` WHERE `lat` >= :where1 AND `lng` >= :where2 AND `lat` <= :where3 AND `lng` <= :where4
在phpMyAdmin中执行原始SQL查询将返回正确的结果,但我的Zend 2.0查询将返回0行
以下是来自Zend的查询结果集的var_转储:
object(Zend\Db\ResultSet\ResultSet)#227 (8) {
["allowedReturnTypes":protected]=>
array(2) {
[0]=>
string(11) "arrayobject"
[1]=>
string(5) "array"
}
["arrayObjectPrototype":protected]=>
object(Application\Model\Venue)#208 (12) {
["id"]=>NULL
["fsq_venue_id"]=>NULL
["name"]=>NULL
["address"]=>NULL
["city"]=>NULL
["state"]=>NULL
["zip"]=>NULL
["country"]=>NULL
["cross_street"]=>NULL
["lat"]=>NULL
["lng"]=>NULL
["updated_at"]=>NULL
}
["returnType":protected]=>
string(11) "arrayobject"
["buffer":protected]=>
NULL
["count":protected]=>
int(0)
["dataSource":protected]=>
object(Zend\Db\Adapter\Driver\Pdo\Result)#214 (8) {
["statementMode":protected]=>
string(7) "forward"
["resource":protected]=>
object(PDOStatement)#215 (1) {
["queryString"]=>
string(117) "SELECT `venues`.* FROM `venues` WHERE `lat` >= :where1 AND `lng` >= :where2 AND `lat` <= :where3 AND `lng` <= :where4"
}
["options":protected]=>
NULL
["currentComplete":protected]=>
bool(false)
["currentData":protected]=>
NULL
["position":protected]=>
int(-1)
["generatedValue":protected]=>
string(1) "0"
["rowCount":protected]=>
int(0)
}
["fieldCount":protected]=>
int(12)
["position":protected]=>
NULL
}
变量未在闭包上下文中设置我想您可以在这里找到答案:[1]:
object(Zend\Db\ResultSet\ResultSet)#227 (8) {
["allowedReturnTypes":protected]=>
array(2) {
[0]=>
string(11) "arrayobject"
[1]=>
string(5) "array"
}
["arrayObjectPrototype":protected]=>
object(Application\Model\Venue)#208 (12) {
["id"]=>NULL
["fsq_venue_id"]=>NULL
["name"]=>NULL
["address"]=>NULL
["city"]=>NULL
["state"]=>NULL
["zip"]=>NULL
["country"]=>NULL
["cross_street"]=>NULL
["lat"]=>NULL
["lng"]=>NULL
["updated_at"]=>NULL
}
["returnType":protected]=>
string(11) "arrayobject"
["buffer":protected]=>
NULL
["count":protected]=>
int(0)
["dataSource":protected]=>
object(Zend\Db\Adapter\Driver\Pdo\Result)#214 (8) {
["statementMode":protected]=>
string(7) "forward"
["resource":protected]=>
object(PDOStatement)#215 (1) {
["queryString"]=>
string(117) "SELECT `venues`.* FROM `venues` WHERE `lat` >= :where1 AND `lng` >= :where2 AND `lat` <= :where3 AND `lng` <= :where4"
}
["options":protected]=>
NULL
["currentComplete":protected]=>
bool(false)
["currentData":protected]=>
NULL
["position":protected]=>
int(-1)
["generatedValue":protected]=>
string(1) "0"
["rowCount":protected]=>
int(0)
}
["fieldCount":protected]=>
int(12)
["position":protected]=>
NULL
}