Re: MySQL Queries - Which to Use?
| From: | _lallous | Date: | Fri, 17 Aug 2001 13:12:55 +0000 |
| Subject: | Re: MySQL Queries - Which to Use? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63169@lists.php.net to get a copy of this message | ||
It all depends on you, I basically get used on using mysql_fetch_array which
returns an associative array.
example:
$result = mysql_query("SELECT name, lastname, age FROM table");
$ra = mysql_fetch_array($result);
or
$ro = mysql_fetch_object($result);
or
$rr = mysql_fetch_row($result);
now:
echo "name is :" . $ra["name"]; // array
(same as: echo "name is:" . $ra[0];
or
echo "name is:" . $ro->name; // object
or
echo "name is:" .$rr[0];
.
.
.
just like the mysql_fetch_array() cause it returns both enumarated and
associative array.
"Kevin" <k@bigsky.net> wrote in message
news:001001c12700$255cb340$503ffea9@kl...
> I have been coding php for a while now but can't seem to get a grasp on
> which type of query I should use for a given situation.
>
> mysql_fetch_array
> mysql_fetch_object
> mysql_fetch_row
>
> Perhaps there is no right answer or perhaps the answer comes with
> experience. In any case, I would love to get some pointers.
>