Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #3674 insert()/update() fails with boolean data type. Data coming from FormBuilder.
Submitted: 2005-03-02 18:55 UTC
From: carlosjordao at gmail dot com Assigned: alan_k
Status: Closed Package: DB_DataObject
PHP Version: 4.3.10 OS: Linux Conectiva 9.0
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 36 + 35 = ?

 
 [2005-03-02 18:55 UTC] carlosjordao at gmail dot com
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 );

Comments

 [2005-03-02 19:07 UTC] pierre at dotgeek dot org
it's a DataObject bug.
 [2005-03-03 03:23 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!