Re: Issues with DB_DataObject toArray
| From: | Justin Patrin | Date: | Fri, 11 Mar 2005 23:02:29 +0000 |
| Subject: | Re: Issues with DB_DataObject toArray | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17977@lists.php.net to get a copy of this message | ||
On Fri, 11 Mar 2005 17:40:00 -0500, Andrew Nagy
<andrew.nagy@villanova.edu> wrote:
> I am using the toArray method for DB_DataObject and one of my mysql
> fields is set to a tinyint (im used to the bit field in postgres) and I
> am using it as a switch. However I extended it to be a 3 way switch
> (which may be bad design) and the 3 values are: 1, 0, null.
>
> When I toArray my DO the 0 and the null are equall (===)
>
> I read through php's docs on assoc arrays and it says that a false value
> should be noted by a 0 integer and a null value is null.
> http://us3.php.net/manual/en/language.types.array.php
>
> Is this a DB_DO bug or a problem elsewhere?
>
> Here is the snippet of code:
> if ($record['status']) {
> return '<img src="images/active.gif" alt="Active">';
> } elseif ($record['status'] === 0) {
> return '<img src="images/review.gif" alt="Needs
> Review">';
> } else {
> return '<img src="images/inactive.gif"
> alt="Inactive">';
> }
>
No time to test this myself, but try to do the query with mysql_query
and mysql_fetch_assoc and see what it returns. Do a var_dump to see if
it's null. If it's unset, that would also work. If you see null or
unset, check the DO fetch() code.
--
Justin Patrin