Question: We are using Symfony to create some webservices. We use Doctrine-ORM to store entities and Doctrine-DBAL to retrive data because it's very light and can reuse the ORM (entity manager) connection.

When using Doctrine-DBAL, integer values are returned to PHP as strings and we want to have integer values, specially because they are retured to Javascript. Following this discussion [How to get numeric types from MySQL using PDO?](https://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo/1197041#1197041) we have installed mysql native driver `sudo apt-get install php5-mysqlnd` and setup our symfony (dbal) configuration with PDO::ATTR\_EMULATE\_PREPARE = false :

```
doctrine:
    dbal:
         .
         .

         options:
            20 : false # PDO::ATTR_EMULATE_PREPARES is 20

```

With this configuration we are getting integers when mysql fields are integers. So far so good.

But there is a new problem: When storing entities with boolean values through Doctrine-ORM the entity is not persisted. We see in the logs the INSERT and the COMMIT, but the record is not in the database (if we use a table with no boolean fields defined in the entity, the record is stored).

Furthermore, we don't get any Error or Exception, so we find this very dangerous. We think there is a bug in the PDO library but we have to look a bit more into it.

The question: Has anybody experienced this behaviour? any workaround? Should Doctrine account for this?

Answer: 
gseric's [answer](https://stackoverflow.com/questions/31089893#answer-35478090) will work but with the effect of hydrating your entities with integers. To still get booleans in your entities you can simply extend Doctrine's `BooleanType`:

```
class BooleanToIntType extends \Doctrine\DBAL\Types\BooleanType
{
    public function getBindingType()
    {
        return \PDO::PARAM_INT;
    }
}

```

Then, in your application bootstrap:

```
\Doctrine\DBAL\Types\Type::overrideType('boolean', BooleanToIntType::class);

```
If it's not too late for you, you can fix this issue in your app bootstrap this way:

```
\Doctrine\DBAL\Types\Type::overrideType('boolean', 'Doctrine\\DBAL\\Types\\IntegerType');

```

After this line is executed Doctrine DBAL will map your PHP boolean values to PDO integers (PDO::PARAM\_INT instead od PDO::PARAM\_BOOL).