Page 1 of 1

Fastest way to retrieve results from db

Posted: Wed Aug 09, 2006 11:43 am
by kingconnections
Ok so I often code things in such a manner:

Code: Select all

dbconnect string 

blah blah 

while ($row = mssql_fetch_assoc($result3)){ 
       			      			
foreach ($row as $col2=>$val2){
do some stuff

}


}
That allows me not to have to reference the columns directly. I could have said

Code: Select all

while ($row = mssql_fetch_assoc($result3)){ 
       			      			
$val=$row['fieldname here'];

}

What is the fastest and most effective way to retrieve the results?

Posted: Wed Aug 09, 2006 12:01 pm
by infolock
The second method.

Posted: Wed Aug 09, 2006 1:31 pm
by Christopher
It really depends on whether you want your code to know the field names or not. If you want code that works with any table then the first one. If you know the specific column names and the code only deals with that table then the second.