Question

According to the PEAR MDB2 documentation, I can optionally quote or not quote values using the third parameter:

$mdb2->quote($val1, "text", true) $mdb2->quote($val2, "integer", false)

Is there a way to enable conversion of blank values to NULL? Ie, if $val1 were empty or actually null, it would appear as NULL in the insert/update statement (instead of '').

Was it helpful?

Solution

Since "a coder" does not have enough reputation to answer, I'm adding his answer to get the question from the unanswered list:


For integers, the solution is to check the value prior to applying $mdb2->quote. If the value is '', then set it to null. The same technique does not work with strings (text) however. Empty text strings converted to null ($textvalue = null) are rendered back to empty strings by

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top