我使用PDO查询我的mysql-db,并使用简单的“SELECT * FROM Invoices”查询。现在,如果我对查询结果执行print_r,那么“bit”类型的所有列都会获得一个空白值
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();
}
}
编辑:忘记提及,行在db
的字段中有值答案 0 :(得分:3)
位字段映射到布尔值。 false
将以您在问题中看到的方式完全打印布尔print_r
。这是一个测试脚本,显示:
$a = array(new stdClass());
$a[0]->Payed = false;
print_r($a);
使用var_dump代替您,您应该能够看到每个属性的数据类型以及布尔内容。