fetching DB entries

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

 



Hi All,

This is just a bit of a 'throw it out to the masses' sort of question to
see what people might recommend.

At the moment, if I am retrieving a single record from the DB, my code
looks like this:

$query = "SELECT * FROM table WHERE id=1";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
    return $row;
}

Now, aside from the actual SQL involved, is this efficient? Would it
gain me anything if I used mysql_result() statements instead, or would
that only be efficient if there were a small number of fields I was
retrieving data for? Should I use something else entirely?

I've not got to the testing this myself, as I figured something like
this might be common knowledge for all of you who are better than me at
optimisation.

Is it even an issue if I'm only retrieving a single record in this
manner (I always make my id field in a table the primary key, so it
means I won't ever be retrieving more than one record)

Thanks in advance for any input you guys have!

Thanks,
Ash
http://www.ashleysheridan.co.uk



[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