Blank values being updated with formbuilder dataobject & DB - possible bug?
| From: | Benjamin Wragg | Date: | Thu, 05 Jan 2006 08:44:16 +0000 |
| Subject: | Blank values being updated with formbuilder dataobject & DB - possible bug? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22442@lists.php.net to get a copy of this message | ||
Hi list,
I'm having a problem with formbuilder, Dataobject & DB using postgresql when
processing a form. If I have a form with some empty fields, when I process
it, I get two single quotes e.g '' put in the string fields and 0 put in
integer fields in the database. Really these should be nulls.
Regarding the string problem, I've used a line by line debugger and followed
it through to line 1227 of DataObject.php where it passes the value of
string (which is an empty string) to $this->_quote. This then passes the
string to the quoteSmart function on line 495 of pgsql.php. Now here I think
is where things go wacky, as the empty string fails all checks and gets
returned using the last else:
return "'" . $this->escapeSimple($in) . "'";
Is this how it should work? IMHO if a field is empty it should be saved as a
null not as ''. A '' in a database field is something! If I go to query a
field where it is null, all the '' won't be returned.
Regarding the integer problem. I've again used a line by line debugger and
followed it through to line 1242 of DataObject.php where it runs intval over
the value returned from the form. Again this value is an empty string with a
length of 0. So intval returns 0 as the value. Again IMHO if a field is
empty it should be stored as null not 0. 0 is definitely something.
So is there a setting somewhere I am missing? Should I be doing something
else that I've missed? Is this a bug?
Cheers,
Benjamin
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.13/221 - Release Date: 4/01/2006