Re: DB_DataObject test for null
| From: | Alan Knowles | Date: | Thu, 24 Aug 2006 09:38:51 +0000 |
| Subject: | Re: DB_DataObject test for null | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24982@lists.php.net to get a copy of this message | ||
Due to limitations in the PHP variable model, you cant reliably do this...
However - you can do something like
$do->selectAs("(mytestcol IS NULL) AS mytestcolIsNull");
.....
if ($do->mytestcolIsNull) {......
Regards
Alan
Chris Domigan wrote:
> Hi everyone,
>
> I'm having trouble working out how to test for a null value using
> DB_DataObject.
>
> If a field is set to NULL, the corresponding property in the data object is
> "", ie blank and not "null". Obviously it's very handy to be able to
> differentiate between an empty string and null.
>
> I've tried using the special sql casts that DB_DataObject supports, but this
> only lets me set null values, which I can already do anyway using
> $object->property = "null".
>
> Any help would be appreciated :)
>
> Chris