You are here: automating the construction of faster queries « PHP SQL « IT news, forums, messages
automating the construction of faster queries

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация