Bug #3674 [NEW]: insert()/update() fails with boolean data type. Data coming from FormBuilder.

From: Date: Wed, 02 Mar 2005 18:55:38 +0000
Subject: Bug #3674 [NEW]: insert()/update() fails with boolean data type. Data coming from FormBuilder.
Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-3930@lists.php.net to get a copy of this message
From: carlosjordao at gmail dot com Operating system: Linux Conectiva 9.0 PHP version: 4.3.10 Package: Bug System Bug Type: Bug Bug description: insert()/update() fails with boolean data type. Data coming from FormBuilder. Description: ------------ This is similar to bug #228 reported before. THE PROBLEM: MySql accepts very well integer 0 and 1 as boolean values 'false' and 'true'. However, PostgreSQL (7.4.6) doesn't act in the same way. It expects explicts 'false' and 'true' strings, or '1' and '0', with quotes. The problem now is that quoteSmart() of pgsql.php may not differ between integer and bool if data has no specific cast to bool. Even as the '18' DataType (STRING & BOOLEAN) field, the function quote() looks for data type through is_boolean(), is_integer(), making the '18' solution senseless (for PostgreSQL). In this case, I use FormBuilder module to do the interface with DataObject, but due the debug() output [the problem is on update()/insert() queries], I suppose the code would fit better here. Reproduce code: --------------- THE SOLUTION: I guess this would help. I have included those lines into my DataObject.php (before $v & DB_DATAOBJECT_STR in insert()) if ($v & DB_DATAOBJECT_BOOL) { $rightq .= $DB->quote((bool)$this->$k) . " "; continue; } (before $v & DB_DATAOBJECT_STR in update()) if ($v & DB_DATAOBJECT_BOOL) { $settings .= "$kSql = ". $DB->quote((bool)$this->$k) . ' '; continue; } Expected result: ---------------- Supose table 'a': CREATE TABLE a ( a bool ); EXPECTED OUPUT: INSERT INTO a (a) VALUES ( TRUE ); (or at least INSERT INTO a (a) VALUES ( '1' ); ) Actual result: -------------- INSERT INTO a (a) VALUES ( 1 ); -- Edit bug report at http://pear.php.net/bugs/bug.php?id=3674&edit=1 --

« previous php.pear.webmaster (#3930) next »