我正在使用 PDO 查询我的 mysql-db,使用普通的“SELECT * FROM Invoices”查询。现在,如果我对查询结果执行 print_r,所有“位”类型的列都会得到一个空白值
Array
(
[0] => stdClass Object
(
[ID] => 1
[Client] => 1
[Title] => Mars 2012
[Issued] => 2012-04-02
[Expiration] => 2012-04-22
[OurReference] => 1
[TheirReference] =>
[Payed] =>
[Sent] =>
)
[1] => stdClass Object
(
[ID] => 2
[Client] => 4
[Title] => Apputveckling
[Issued] => 2012-04-30
[Expiration] => 2012-05-21
[OurReference] => 1
[TheirReference] =>
[Payed] =>
[Sent] =>
)
[2] => stdClass Object
(
[ID] => 3
[Client] => 4
[Title] => Administration
[Issued] => 2012-05-28
[Expiration] => 2012-06-18
[OurReference] => 1
[TheirReference] =>
[Payed] =>
[Sent] =>
)
)
怎么可能?这是我使用的getData方法
public function getData($sql, $data = null)
{
$statement = $this->query($sql, $data);
try
{
$result = $statement->fetchAll();
}
catch(Exception $e)
{
echo "Error: " . $e->getMessage() . " ";
return array();
}
if(count($result) > 1)
{
return $result;
}
else if(count($result) == 1)
{
return $result[0];
}
else
{
return array();
}
}
编辑:忘了提,这些行在数据库中的字段中确实有值