I'm using DBAL in a Symfony project to access data in a Mysql database. When querying tables with boolean fields (created as tinyint) I get tinyint values in PHP but I would like to get booleans.
Somehow, I'd like to get the same mapping as using Doctrine directly.
I thought that the mapping conversion (from mysql to php) was already implemented in DBAL, but I'm not sure if it's suppose to work this way (this layer mapping values back).
I have tried registering a custom mapping like the following one, but no success:
$this->conn->getDatabasePlatform()->registerDoctrineTypeMapping('tinyint', 'boolean');
$sql = "
SELECT se.survey_id, se.anonymous
FROM survey_edition se
";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetch();
In this case 'anonymous' is a tinyint(1) field in Mysql, but I would like that $result['anonymous'] to be a boolean instead of an integer.
Do you know if it is possible to get boolean values in PHP from a Mysql query through Doctrine's DBAL?
Thanks.