我有以下代码块,预计将返回count
$sql = "SELECT sum(count) as count
FROM multipleowners WHERE owner = ? " . $localityquery;
$queryarray = array($owner, $locality);
$query = $this->db->query($sql, $queryarray);
if ($query->num_rows() > 0)
{
$result = $query->row_array();
$count = $result['count'];
}
但是当我尝试打印时,我得到了空值$count
。
我用过print_r($this->db->last_query());
,我得到了以下查询,
SELECT sum(count) as count FROM multipleowners WHERE owner = 'Davenports Harbour Trustee (2012) Limited' and locality = 'Auckland Central'
当我直接在我的身上执行这个查询时,我Postgresql
IDE
得到了count
as的输出2
。
这个查询会出现什么问题以及在哪里出错?我怀疑从句中(
and)
的存在。WHERE
我该如何解决 ?
更新
当我启用探查器时,我得到了以下查询,
SELECT sum(count) as count
FROM multipleowners WHERE owner = 'Davenports Harbour Trustee (2012) Limited' and locality = 'Auckland Central'
所以很明显问题存在于(
and )
!!