简体   繁体   English

MDB2引号-空值?

[英]MDB2 quotes — null values?

According to the PEAR MDB2 documentation, I can optionally quote or not quote values using the third parameter: 根据PEAR MDB2文档,我可以选择使用第三个参数引用或不引用值:

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

Is there a way to enable conversion of blank values to NULL? 有没有一种方法可以将空值转换为NULL? Ie, if $val1 were empty or actually null, it would appear as NULL in the insert/update statement (instead of ''). 即,如果$ val1为空或实际上为null,则它将在insert / update语句中显示为NULL(而不是“”)。

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. 对于整数,解决方案是在应用$ mdb2-> quote之前检查该值。 If the value is '', then set it to null. 如果值为,则将其设置为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 转换为空($ textvalue = null)的空文本字符串将通过以下方式转换回空字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM