diff --git a/html/pages/routing.inc.php b/html/pages/routing.inc.php
index 9d35968f6..272ed2ecb 100644
--- a/html/pages/routing.inc.php
+++ b/html/pages/routing.inc.php
@@ -19,7 +19,7 @@ print_optionbar_start();
echo("
» ");
unset($sep);
-foreach ($datas as $type)
+foreach ($routing_count as $type => $value)
{
if (!$_GET['opta']) { $_GET['opta'] = $type; }
diff --git a/html/pages/routing/ospf.inc.php b/html/pages/routing/ospf.inc.php
index c4ded7eda..fc5b75676 100644
--- a/html/pages/routing/ospf.inc.php
+++ b/html/pages/routing/ospf.inc.php
@@ -1,8 +1,5 @@
');
@@ -10,7 +7,7 @@ echo('
| Device | Router Id | Status | ABR | ASBR
#### Loop Instances
-while ($instance = mysql_fetch_assoc($query))
+foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled'") as $instance)
{
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; }
diff --git a/html/pages/routing/vrf.inc.php b/html/pages/routing/vrf.inc.php
index f3d96f0a1..4ead4b340 100644
--- a/html/pages/routing/vrf.inc.php
+++ b/html/pages/routing/vrf.inc.php
@@ -53,9 +53,8 @@ if($_GET['optb'] == "all" ) {
echo(" | " . $vrf['mplsVpnVrfRouteDistinguisher'] . " | ");
#echo("" . $vrf['mplsVpnVrfDescription'] . " | ");
echo("");
- $devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
- while ($device = mysql_fetch_assoc($devices))
+ foreach (dbFetchRows("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = ? AND D.device_id = V.device_id", array($vrf['mplsVpnVrfRouteDistinguisher'])) as $device)
{
if (!is_integer($i/2))
{
diff --git a/includes/dbFacile.php b/includes/dbFacile.php
index 39717bc11..3b32757ac 100644
--- a/includes/dbFacile.php
+++ b/includes/dbFacile.php
@@ -135,6 +135,7 @@ function dbDelete($table, $where = null, $parameters = array()) {
* Most other retrieval functions build off this
* */
function dbFetchRows($sql, $parameters = array()) {
+ global $db_stats;
$result = dbQuery($sql, $parameters);
if(mysql_num_rows($result) > 0) {
$rows = array();
@@ -144,7 +145,14 @@ function dbFetchRows($sql, $parameters = array()) {
mysql_free_result($result);
return $rows;
}
- mysql_free_result($result);
+
+ $time_start = microtime(true);
+ mysql_free_result($result);
+ $time_end = microtime(true);
+
+ $db_stats['fetchrows_sec'] += number_format($time_end - $time_start, 8);
+ $db_stats['fetchrows']++;
+
// no records, thus return empty array
// which should evaluate to false, and will prevent foreach notices/warnings
return array();
@@ -172,10 +180,20 @@ function dbFetch($sql, $parameters = array()) {
* The first argument is an sprintf-ready query stringTypes
* */
function dbFetchRow($sql = null, $parameters = array()) {
+ global $db_stats;
+ $time_start = microtime(true);
+
$result = dbQuery($sql, $parameters);
+ $time_start = microtime(true);
+
if($result) {
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
+ $time_end = microtime(true);
+
+ $db_stats['fetchrow_sec'] += number_format($time_end - $time_start, 8);
+ $db_stats['fetchrow']++;
+
return $row;
} else {
return null;
@@ -186,10 +204,18 @@ function dbFetchRow($sql = null, $parameters = array()) {
* Fetches the first call from the first row returned by the query
* */
function dbFetchCell($sql, $parameters = array()) {
+ global $db_stats;
+ $time_start = microtime(true);
+
$row = dbFetchRow($sql, $parameters);
if($row) {
return array_shift($row); // shift first field off first row
}
+ $time_end = microtime(true);
+
+ $db_stats['fetchcell_sec'] += number_format($time_end - $time_start, 8);
+ $db_stats['fetchcell']++;
+
return null;
}
@@ -198,10 +224,17 @@ function dbFetchCell($sql, $parameters = array()) {
* It fetches one cell from each row and places all the values in 1 array
* */
function dbFetchColumn($sql, $parameters = array()) {
+ global $db_stats;
+ $time_start = microtime(true);
$cells = array();
foreach(dbFetch($sql, $parameters) as $row) {
$cells[] = array_shift($row);
}
+ $time_end = microtime(true);
+
+ $db_stats['fetchcol_sec'] += number_format($time_end - $time_start, 8);
+ $db_stats['fetchcol']++;
+
return $cells;
}
|
|---|