In our project we use native MySQL queries to fetch our data. This way we can skip the heavy ORM part but this made us run into an annoying issue. When ever we did a select that should return an integer it was transformed into a string.
$sql = "SELECT g.position FROM goal g";
$stmt = $this->conn->executeQuery($sql);
'position' => string '2' (length=1)
'position' => string '1' (length=1)
So you can see our query did return the all the positions we found but they were all transformed into strings although we have them declared as Integers.
How can we fix this?
STEP 1: Install the MySQL Native Driver and remove the old one
sudo apt-get remove php5-mysql
sudo apt-get install php5-mysqlnd
STEP 2: Change option 20 in your doctrine settings
$params = array(
'driver' => 'pdo_mysql',
'dbname' => 'mydb',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'charset' => 'utf8',
'driverOptions' => array(
PDO::ATTR_EMULATE_PREPARES => FALSE
20 = PDO::ATTR_EMULATE_PREPARES
'position' => int 2
'position' => int 1
Extra thanks: @wmolenberghs
All my tips have been moved to my blog www.pix-art.be so come check it out!