News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot:
MySQL 5.6 BOOL behavior when using PDO and prepared statements
December 05, 2013 @ 10:37:42

Evert Pot was seeing some weird issues with his MySQL BOOL usage via PDO when he upgraded to one of the latest versions (5.6). Thankfully, he's shared his solution to the problem as well as the symptoms he was seeing when it was causing problems.

I recently updated my workstation to run MySQL 5.6.13. It didn't take very long for things to start breaking, and since I couldn't find any other information about this on the web, I figured this may be useful to someone else. The main error that started popping up was: "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'my_bool' at row 1' in test.php" This exception happens under the condition that you use PDO, prepared statements and booleans.

He includes a small sample script to reproduce the issue and points out the issue - the default casting of prepared values to strings in prepared statements with PDO bound parameters. He shows two "relatively easy solutions" to the problem - either using integers instead of the true/false PHP boolean or specifying a type with the bindValue call.

0 comments voice your opinion now!
mysql upgrade boolean field pdo prepared statement

Link: http://evertpot.com/mysql-bool-behavior-and-php/

blog comments powered by Disqus

Similar Posts

Martynas Jusevicius' Blog: Calculating great-circle distance in MySQL and Propel

SitePoint PHP Blog: Laravel 4 to Laravel 5 The Simple Upgrade Guide

John Coggeshall's Blog: Compiling extensions for Zend Core

Hasin Hayder: Upgrading PHP to 5.5 in a CentOS 6 server with Vesta CP

PHPMaster.com: Working with Dates and Times in PHP and MySQL


Community Events

Don't see your event here?
Let us know!


conference laravel example performance library voicesoftheelephpant podcast introduction interview symfony2 api application framework community language configure series opinion php7 release

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework