News Feed
Sections




News Archive
feed this:

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/

DevShed:
Validating Boolean Values and Float Numbers with Filters in PHP 5
August 06, 2009 @ 07:51:05

Continuing their "validation in PHP" series, DevShed has posted this new tutorial looking at the validation of boolean values and float numbers in PHP5 applications (with the filter extension).

As you learned in previous parts of the series, the filter extension permits you to validate elements of a given array very easily as well. Therefore, in this fourth chapter I'm going to explain how to check for Boolean values in arrays, as well as how to validate float numbers using another handy filter.

the examples are pretty simple, running a filter_var on the values to check if it's a boolean and to require that the set of values comes in as an array.

1 comment voice your opinion now!
tutorial boolean filter extension float


DevShed:
Checking Boolean Values with Filters in PHP 5
July 30, 2009 @ 09:09:12

DevShed continues their look at filtering in PHP5 applications with this third part covering checks on boolean values.

As I said before, the filter extension can be used for more than validating integers, since it provides the required functionality to checking other data types. Thus, in the next few lines I'm going to discuss how to use the extension for validating Boolean values.

They give a few lines of example code to show how different values (like "1" versus 1 and "true" versus true) are affected by PHP's dynamic typing.

0 comments voice your opinion now!
boolean value tutorial filter extension


DevShed:
Performing Full-text and Boolean Searches with MySQL
June 06, 2007 @ 14:06:00

DevShed has started a new MySQL-centric series today with this new tutorial, an initial look at working with MySQL and PHP to perform full-text and boolean searches on your data.

In this series of articles I'm going to show you how to work with full-text and Boolean searches using MySQL and PHP 5, but the entirety of the code samples that will be developed here can be easily modified to work with a different database server.

They start with the creation of a "common approach" for making the requests and fetching the results (in classes so that any other database could be substituted). With the class structure in place, they move on to the full-text searches, showing how to format database tables by creating them with a fulltext index on which ever fields you want.

0 comments voice your opinion now!
mysql boolean search fulltext table database tutorial mysql boolean search fulltext table database tutorial



Community Events





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


threedevsandamaybe tips development interview code api conference deployment zendserver series list podcast release language laravel community bugfix framework symfony introduction

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