optimized a bit (mainly added some 'mysql_free_result')

This commit is contained in:
Loïc Chapeaux
2001-09-06 18:34:41 +00:00
parent 1512bbcf26
commit f4f72557f3
6 changed files with 25 additions and 14 deletions

View File

@@ -61,6 +61,7 @@ else {
</table>
<?php
} // end if
mysql_free_result($tables);
/**

View File

@@ -205,6 +205,7 @@ if ($server > 0
break;
}
}
mysql_free_result($tables);
}
// The user is allowed to create a db
if ($create) {

View File

@@ -30,6 +30,7 @@ if (MYSQL_INT_VERSION >= 32300) {
if (!empty($row['Comment'])) {
echo $strTableComments . '&nbsp;:&nbsp;' . $row['Comment'];
}
mysql_free_result($result);
} // end display comments
@@ -108,6 +109,8 @@ while ($row = mysql_fetch_array($result)) {
</tr>
<?php
} // end while
mysql_free_result($result);
echo "\n";
?>
</table>
@@ -148,6 +151,7 @@ if (mysql_num_rows($result) > 0) {
</table>
<?php
} // end if
mysql_free_result($result);
/**

View File

@@ -301,9 +301,11 @@ if ($action == 'tbl_create.php3' && MYSQL_INT_VERSION >= 32300) {
}
break;
} // end switch
}
}
}
} // end if
} // end while
} // end if
mysql_free_result($tables);
echo "\n";
?>
<td width="25">&nbsp;</td>

View File

@@ -102,9 +102,10 @@ if ($row < 0) {
/**
* Prepares the form
*/
$tbl_result = mysql_list_tables($db);
$i = 0;
$k = 0;
$tbl_result = mysql_list_tables($db);
$tbl_result_cnt = mysql_num_rows($tbl_result);
$i = 0;
$k = 0;
// The tables list sent by a previously submitted form
if (!empty($TableList)) {
@@ -114,10 +115,11 @@ if (!empty($TableList)) {
} // end if
// The tables list gets from MySQL
while ($i < mysql_num_rows($tbl_result)) {
$tbl = mysql_tablename($tbl_result, $i);
$fld_results = mysql_list_fields($db, $tbl);
$j = 0;
while ($i < $tbl_result_cnt) {
$tbl = mysql_tablename($tbl_result, $i);
$fld_results = mysql_list_fields($db, $tbl);
$fld_results_cnt = mysql_num_fields($fld_results);
$j = 0;
if (empty($tbl_names[$tbl]) && !empty($TableList)) {
$tbl_names[$tbl] = '';
@@ -128,16 +130,18 @@ while ($i < mysql_num_rows($tbl_result)) {
// The fields list per selected tables
if ($tbl_names[$tbl] == ' selected="selected"') {
$fld[$k++] = backquote($tbl) . '.*';
while ($j < mysql_num_fields($fld_results)) {
while ($j < $fld_results_cnt) {
$fld[$k] = mysql_field_name($fld_results, $j);
$fld[$k] = backquote($tbl) . '.' . backquote($fld[$k]);
$k++;
$j++;
} // end while
} // end if
mysql_free_result($fld_results);
$i++;
} // end if
mysql_free_result($tbl_result);
/**

View File

@@ -93,10 +93,9 @@ if (!isset($param) || $param[0] == '') {
<option value="--nil--"></option>
<?php
echo "\n";
for ($i = 0; $i < mysql_num_fields($result); $i++) {
$field = mysql_field_name($result, $i);
for ($i = 0; $i < $fields_count; $i++) {
echo ' ';
echo '<option value="' . urlencode($field) . '">' . htmlspecialchars($field) . '</option>' . "\n";
echo '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
} // end for
?>
</select>