0

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 '').

a coder
  • 7,530
  • 20
  • 84
  • 131
  • please add that as an answer or close the question. – cweiske Oct 06 '11 at 07:54
  • 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 **quote**. – a coder Oct 06 '11 at 11:20
  • It's not allowing me to answer this question. – a coder Oct 06 '11 at 11:20

1 Answers1

0

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

cweiske
  • 30,033
  • 14
  • 133
  • 194