Hello,
on 02/17/2005 03:42 AM idiroddi said the following:
> Before I tried Metabase for the first time (last week) i used:
>
> //create select list options (id,lname,fname)
> $options_agents=array(""=>"Select an Agent");
> while($row=mysql_fetch_row($result_agents))
> $options_agents[$row[0]]=$row[1].', '.$row[2];
>
>
> As I'm playing with Metabase, I tried with no success:
>
> //create select list options (id,lname,fname)
> $options_agents=array(""=>"Select an Agent");
> while($row=MetabaseFetchResult($database,$result_agents,0,"fname"))
> $options_agents[$row[0]]=$row[1].', '.$row[2];
>
> What is the portable mysql alternative?
for($line=0; !MetabaseEndOfResult($database, $result) &&
MetabaseFetchResultArray($database, $result, $row, $line); $line++)
$options_agents[$row[0]]=$row[1].', '.$row[2];
> Also, is there an alternative for:
> while($row=mysql_fetch_array($result)){
> $name = $row["name"];
> }
Sorry no. There is no portable way for fetching column values by name
because each database may change the case or truncate the returned
column names in an unpredictable way.
You can always use defines like this:
define("NAME", 0);
$name=$row[NAME];
Just take care that defines are global.
> BTW, as with your other classes, Great Great work!
Thank you. ;-)
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html