I am querying my mysql-db using PDO, with a plain “SELECT * FROM Invoices” query. Now all columns of type “bit” gets a blank value if i do print_r on the result from the query
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] =>
)
)
How can that be?
This is the getData-method im using
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();
}
}
EDIT: Forgot to mention, the rows do have values in the fields in the db
The bit fields are mapped to booleans. A boolean
falsewill be printed byprint_rin exactly the way you see in your question. Here is a test script showing that:Use var_dump instead and you should be able to see both the datatype of each property as well as the boolean content.