aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-10-30 15:42:29 +0000
committerz0rglub <z0rglub@piwigo.org>2004-10-30 15:42:29 +0000
commit7cd9b65e3299fb8bc6a83e65f89fcecca62f3178 (patch)
treee068090892b16db654a2bf0c2886b65eaf44a14f /include/functions.inc.php
parent3730c810f254267ab1fb49f4cad55866e780ad6e (diff)
- function mysql_query replaced by pwg_query : the same with debugging
features - by default, DEBUG is set to 0 (off) git-svn-id: http://piwigo.org/svn/trunk@587 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php40
1 files changed, 22 insertions, 18 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 82577b66e..af2c6d6b3 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -51,7 +51,7 @@ function get_enums( $table, $field )
{
// retrieving the properties of the table. Each line represents a field :
// columns are 'Field', 'Type'
- $result=mysql_query("desc $table");
+ $result=pwg_query("desc $table");
while ( $row = mysql_fetch_array( $result ) )
{
// we are only interested in the the field given in parameter for the
@@ -350,7 +350,7 @@ function pwg_log( $file, $category, $picture = '' )
$query.= " (NOW(), '".$user['username']."'";
$query.= ",'".$_SERVER['REMOTE_ADDR']."'";
$query.= ",'".$file."','".$category."','".$picture."');";
- mysql_query( $query );
+ pwg_query( $query );
}
}
@@ -408,7 +408,7 @@ function notify( $type, $infos = '' )
$query.= " WHERE status = 'admin'";
$query.= ' AND mail_address IS NOT NULL';
$query.= ';';
- $result = mysql_query( $query );
+ $result = pwg_query( $query );
while ( $row = mysql_fetch_array( $result ) )
{
$to = $row['mail_address'];
@@ -444,22 +444,26 @@ function pwg_write_debug()
fclose( $fp );
}
-function pwg_query( $query )
+function pwg_query($query)
{
- global $count_queries,$queries_time;
-
$start = get_moment();
- $output = '';
-
- $count_queries++;
- $output.= '<br /><br />['.$count_queries.'] '.$query;
- $result = mysql_query( $query );
- $time = get_moment() - $start;
- $queries_time+= $time;
- $output.= '<b>('.number_format( $time, 3, '.', ' ').' s)</b>';
- $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)';
-
- // echo $output;
+ $result = mysql_query($query);
+
+ if (DEBUG)
+ {
+ global $count_queries,$queries_time;
+
+ $time = get_moment() - $start;
+ $count_queries++;
+
+ $output = '';
+ $output.= '<pre>['.$count_queries.'] '."\n".$query;
+ $queries_time+= $time;
+ $output.= "\n".'(this query time : '.number_format( $time, 3, '.', ' ').' s)</b>';
+ $output.= "\n".'(total SQL time : '.number_format( $queries_time, 3, '.', ' ').' s)';
+ $output.= '</pre>';
+ echo $output;
+ }
return $result;
}
@@ -594,4 +598,4 @@ function get_thumbnail_src($file, $storage_category_id, $tn_ext = '')
return $src;
}
-?> \ No newline at end of file
+?>