开发者

MDB2 quotes -- null values?

开发者 https://www.devze.com 2023-04-11 15:03 出处:网络
According to the PEAR MDB2 documentation, I can optionally quote or not quote values using the third parameter:

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

$mdb2->quote(开发者_C百科$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 '').


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

0

精彩评论

暂无评论...
验证码 换一张
取 消