All,
This is a function that I use quite often. I pass in my SQL string and
return the results as an array. Does anyone see any optimizations that I can
make (eventually I would like to make a class, but I am still new).
function table_array ($sql_string)
{
$result = mysql_query($sq l_string) or die("dead");
$num_rows = mysql_num_rows( $result);
$num_fields = mysql_num_field s($result);
$j = 0;
$x = 1;
while ($row = mysql_fetch_arr ay($result)) {
for($j = 0;$j < $num_fields;$j+ +) {
$name = mysql_field_nam e($result, $j);
$arr[$x][$name] = $row[$name];
}
$x++;
}
return array('arr' => $arr, 'rows' => $num_rows, 'fields' => $num_fields);
}
Always trying to shave off some access times =)
Thanks.
This is a function that I use quite often. I pass in my SQL string and
return the results as an array. Does anyone see any optimizations that I can
make (eventually I would like to make a class, but I am still new).
function table_array ($sql_string)
{
$result = mysql_query($sq l_string) or die("dead");
$num_rows = mysql_num_rows( $result);
$num_fields = mysql_num_field s($result);
$j = 0;
$x = 1;
while ($row = mysql_fetch_arr ay($result)) {
for($j = 0;$j < $num_fields;$j+ +) {
$name = mysql_field_nam e($result, $j);
$arr[$x][$name] = $row[$name];
}
$x++;
}
return array('arr' => $arr, 'rows' => $num_rows, 'fields' => $num_fields);
}
Always trying to shave off some access times =)
Thanks.
Comment