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> </table>
<?php <?php
} // end if } // end if
mysql_free_result($tables);
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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