|
Posted by Rik on 07/11/06 13:38
David Haynes wrote:
> Rik wrote:
>>> $row['isarchived'] is already a 0/1 value (Tinyint(1)), so really
>>> the (bool) cast is a no-op. My bad. You could just use $isArchived =
>>> $row['isarchived']
>>
>> What do you mean by no-op? I'm no native speaker, please explain.
>> And already 0/1? 0/1 is an integer, not a boolean.
>
> Due to the loose type association false (boolean) == 0 (integer).
> Similarly, true (boolean) == (not) 0 (integer)
>
> So, given that a Tinyint(1) can only return 0 and 1 this has a direct
> 1:1 mapping through the implied type casting of PHP to false and true.
>
> That's what I meant by no-op (PHP will handle it for you)
It does in most cases, however, if one states:"I would translate the 0/1
from MySQL into true/false at the lowest level I could.", one provides an
answer :-).
Grtz,
--
Rik Wasmus
[Back to original message]
|