Re: Posting a variable
| From: | Richard Lynch | Date: | Thu, 12 Apr 2007 01:12:28 +0000 |
| Subject: | Re: Posting a variable | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252665@lists.php.net to get a copy of this message | ||
On Wed, April 11, 2007 12:53 pm, siavash1979@telus.net wrote:
> Quoting Robert Cummings <robert@interjinn.com>:
>
>> On Wed, 2007-04-11 at 09:59 -0700, siavash1979@telus.net wrote:
>> > 1- your mysql query statement is better to have a WHERE part too.
>> > 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
>>
>> Ummm, why would you want to reduce clarity and maintainability by
>> using
>> mysql_fetch_row()?
>
> hmmm, I just remember in my php class a while back, my teacher didn't
> even
> bother teaching us about mysql_fetch_assoc, and when a student asked
> about it,
> he said don't bother using it, just use mysql_fetch_row so I ended up
> using this
> function ever since. I'm guessing he was wrong??
He wasn't "wrong"
It's a religious question.
I find mysql_fetch_assoc to be less clear because you end up not
necessarily using the data until much later, and by the time you get
to the line that has:
$row['foozie']
in it, you've lost track of what 'foozie' is...
I try to get my SELECT statement and a line with $foozie "near" each
other:
$query = "select .... as foozie from whatsit where umnh-hunh";
$whatever = mysql_query($query, $connection);
if (!$connection){
//insert proper error handling here
}
while (list($foozie) = mysql_fetch_row($whatever)){
}
But this is really just a religious question, and there are many other
equally valid idioms.
YMMV
IANAL
NAIAA
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?