|
Posted by Jim Michaels on 01/23/06 03:25
I also hear it's slower (from another post) than using the direct mysql
functions.
If you want to build an array from the database, you could do this:
$a=array();
$q=mysql_query("SELECT * FROM tablename", $link);
while($row=mysql_fetch_array($q)) {
$a[] = $row;
}
foreach ($a as $row) {
//do whatever with things like $row['item']
}
or you could use a SELECT to create a temporary table and grab your data
from that, and then destroy the temporary table. either way works, depends
on whether you need a snapshot or whether you are willing to work with live
rows. MySQL has row locking.
"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:h3rqs15rcpbmm1q61h1sijmgg20s3duteo@4ax.com...
> On 17 Jan 2006 11:34:37 -0800, sam.s.kong@gmail.com wrote:
>
>>> Rather than re-invent the wheel, look at:
>>>
>>> http://adodb.sourceforge.net/
>>> http://phplens.com/adodb/reference.functions.getarray.html
>>
>>Thanks for the answer.
>>My intention is not to use ADO db but make DB-accessing code simple and
>>avoid repeated codes (connecting/freeing/disconnecting db).
>>Is there a best practice of db-accessing in PHP?
>
> You do realise that other than the name and a deliberate similarity in
> function names, ADOdb has nothing to do with Microsoft ADO - it's just a
> thin
> PHP library providing the sort of access methods you're talking about on
> top of
> various PHP native database access functions?
>
> IMHO, ADOdb _is_ the best practice of accessing databases in PHP.
>
> --
> Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
> http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|