Blank value problem with db+dataobject+formbuilder
| From: | Benjamin Wragg | Date: | Thu, 02 Mar 2006 04:51:37 +0000 |
| Subject: | Blank value problem with db+dataobject+formbuilder | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-23187@lists.php.net to get a copy of this message | ||
Hi all,
I'm having a problem when using 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 rather than null values.
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?
Cheers,
Benjamin
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/272 - Release Date: 1/03/2006