|
Posted by David Haynes on 07/11/06 10:16
Rik wrote:
> David Haynes wrote:
>> $result = mysqli_query($sql);
>> while( $row = mysql_fetch_assoc($result) ) {
>> $isArchived = $row['is_archived'] ? true : false;
>> ...
>> }
>
>
> $isArchived = (bool)$row['isarchived'];
> it's shorter, and by using $row['is_archived'] ? you're already evaluating
> the boolean value.
>
>
> http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
>
> Grtz,
Rik,
$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']
-david-
Navigation:
[Reply to this message]
|