Re: newbie PDO query display question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> 
>> 
> When you know there is only one row to be returned you can do this:
> 
> $photo_category_list = "";
>   $SQL = "SELECT category_id, category_name FROM gallery_category ORDER by category_order";
>   try {
>       $stmt = $dbh->prepare($SQL);
>       $stmt->execute();
>       list( $id, $name) = $stmt->fetch(PDO::FETCH_NUM));
>      }
>   }
>   catch (PDOException $e){
>       echo 'Error getting category name. ' . $e->getMessage();
>   }
> 
> echo $id;
> echo $name;
> 
> And you could also do
> 
>       list( $result["id"], $result["name"]) = $stmt->fetch(PDO::FETCH_NUM));
> 
> 
> -- 
> Stephen
> 

Thanks very much for your help Stephen - I will try this asap!




--
Thanks,
Dave - DealTek
dealtek@xxxxxxxxx
[db-3]


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux