Permalink
Browse files

The number of SQL queries and the number of fetched rows are now prin…

…ted for each

generated web page.

Signed-off-by: Sébastien Boisvert <sebastien.boisvert.3@ulaval.ca>
  • Loading branch information...
1 parent f78ab1b commit 2679e9ac319a883c62e2396573ae3837a13ace3c @sebhtml committed Jul 12, 2012
Showing with 37 additions and 4 deletions.
  1. +4 −1 app/Core.php
  2. +25 −2 app/Driver.php
  3. +8 −1 app/views/Template/template.php
View
@@ -166,7 +166,10 @@ public function call(){
$CONFIG_style=$this->m_sheet;
$softwareName="cooprouelibre-StarFleetManager";
- $softwareVersion="v1.4.0";
+ $softwareVersion="v1.6.0";
+
+ $rows=$this->m_databaseConnection->getFetchedRows();
+ $queries=$this->m_databaseConnection->getProcessedSQLQueries();
include("app/views/Template/template.php");
}
View
@@ -7,8 +7,9 @@
class Result{
private $m_result;
+ private $m_driver;
- public function __construct($result){
+ public function __construct($result,$driver){
//echo "Building result with $result<br />";
@@ -17,13 +18,16 @@ public function __construct($result){
}
$this->m_result=$result;
+ $this->m_driver=$driver;
}
public function getRow(){
if(!$this->m_result){
return false;
}
+ $this->m_driver->addRow();
+
return mysql_fetch_assoc($this->m_result);
}
@@ -42,6 +46,8 @@ public function getRows(){
class Driver{
private $m_connection;
+ private $m_queries;
+ private $m_rows;
public function connect($host,$user,$password,$database){
$this->m_connection=mysql_pconnect($host,$user,$password);
@@ -53,6 +59,9 @@ public function connect($host,$user,$password,$database){
}
mysql_select_db($database,$this->m_connection);
+
+ $this->m_rows=0;
+ $this->m_queries=0;
}
public function query($query){
@@ -76,7 +85,9 @@ public function query($query){
echo "</div>";
}
- return new Result($result);
+ $this->m_queries++;
+
+ return new Result($result,$this);
}
public function getInsertedIdentifier(){
@@ -86,6 +97,18 @@ public function getInsertedIdentifier(){
public function escapeString($string){
return mysql_real_escape_string($string);
}
+
+ public function addRow(){
+ $this->m_rows++;
+ }
+
+ public function getFetchedRows(){
+ return $this->m_rows;
+ }
+
+ public function getProcessedSQLQueries(){
+ return $this->m_queries;
+ }
}
@@ -110,7 +110,14 @@
<a href="http://www.gnu.org/licenses/gpl-3.0.html">Licence publique générale GNU, version 3</a>.
</small>
</div>
-
+<div>
+<br />
+<i>
+<?php echo $queries ; ?> requêtes SQL exécutées; <?php echo $rows; ?> lignes obtenues
+</i>
+<br />
+</div>
+</div>
</div>

0 comments on commit 2679e9a

Please sign in to comment.