| 
	
 | 
 Posted by strawberry on 05/21/06 20:40 
After reading somewhere in one of these NGs that naming all the fields 
in a query produced faster searches than "SELECT *..." I've rewritten 
my queries as follows: 
 
$table = words; 
$describe = "DESCRIBE $table;"; 
$field_array = mysql_query($describe) or die ("Couldn't execute 
query."); 
 
while ($row = mysql_fetch_assoc($field_array)) 
{ 
$fields .= $row["Field"] . ", "; 
} 
$fields = substr($fields, 0, -2); //trim last comma 
 
echo $fields; 
 
$query = "SELECT $fields FROM $table etc, etc" 
 
This works but looks extremely long-winded. I bet there's a much more 
efficient way of doing this, isn't there?
 
  
Navigation:
[Reply to this message] 
 |