我想知道我做错了什么。这是我的课。
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Sql;
use Zend\Db\Sql\Select;
class Country
{
protected $_dbA;
protected $_sql;
public function __construct(Adapter $dbA) {
$this->_dbA = $dbA;
$this->_sql = new Sql($this->_dbA);
}
public function getCity()
{
$select = new Select();
$sql = $select->from('es')
->columns(array('City'))
->where(array('ZIP' => 28934));
if (is_string($sql)) {
$stm = $this->_dbA->createStatement($sql);
} else {
$stm = $this->_dbA->createStatement();
$sql->prepareStatement($this->_dbA, $stm);
}
return $stm->execute();
}
}
和 VAR_DUMP 在运行函数 getCity()
object(Zend\Db\Adapter\Driver\Pdo\Result)#332 (8) {
["statementMode":protected]=>
string(7) "forward"
["resource":protected]=>
object(PDOStatement)#331 (1) {
["queryString"]=>
string(60) "SELECT `es`.`City` AS `City` FROM `es` WHERE `ZIP` = :where1"
}
["options":protected]=>
NULL
["currentComplete":protected]=>
bool(false)
["currentData":protected]=>
NULL
["position":protected]=>
int(-1)
["generatedValue":protected]=>
string(1) "0"
["rowCount":protected]=>
NULL
}
我在谷歌搜索之前在这里发布并尝试了很多东西但结果相同。我无法从数据库中检索任何数据。