diff --git a/library/framework/common/mysql.new.php b/library/framework/common/mysql.new.php index 77857bd7..e839d9e5 100644 --- a/library/framework/common/mysql.new.php +++ b/library/framework/common/mysql.new.php @@ -34,7 +34,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + $fields = implode(array_keys($toAdd), ','); foreach (array_values($toAdd) as $key=>$array_values) $tmp[$key]=checkaddslashes($array_values); @@ -81,7 +81,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + if ($low_priority) { $query='UPDATE LOW_PRIORITY '.$table.' SET '; } else { @@ -131,11 +131,11 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + if ($low_priority) - $query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;'; + $query='DELETE LOW_PRIORITY QUICK FROM '.$table.' WHERE '.$where.' LIMIT 1;'; else - $query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;'; + $query='DELETE FROM '.$table.' WHERE '.$where.' LIMIT 1;'; if ($debug) $tdeb=microtime_float(); @@ -171,7 +171,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + $query="SELECT $fields FROM $table WHERE $where;"; if ($debug) $tdeb=microtime_float(); @@ -241,7 +241,12 @@ class WDB } else { $duree = 'N/D'; } - file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND); + if ($this->errorCode == 0) { + $msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; + } else { + $msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; + } + file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND); } /** @@ -251,7 +256,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + try { $stmt = $this->db->query($query); $this->result = $stmt; @@ -307,7 +312,7 @@ class WDB $nbLignes = count($res); for($i=0; $i<$nbLignes; $i++) { $ligne = $res[$i]; - + //Header if ($i==0) { $nbCols = count($ligne); @@ -317,7 +322,7 @@ class WDB } fputcsv($fp, $header, $sep, '"'); } - + //Content $fields = array(); foreach ($ligne as $libCol => $col) { @@ -325,7 +330,7 @@ class WDB } fputcsv($fp, $fields, $sep, '"'); } - + fclose($fp); return $nbLignes; } diff --git a/library/framework/common/mysql.php b/library/framework/common/mysql.php index 77857bd7..e839d9e5 100644 --- a/library/framework/common/mysql.php +++ b/library/framework/common/mysql.php @@ -34,7 +34,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + $fields = implode(array_keys($toAdd), ','); foreach (array_values($toAdd) as $key=>$array_values) $tmp[$key]=checkaddslashes($array_values); @@ -81,7 +81,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + if ($low_priority) { $query='UPDATE LOW_PRIORITY '.$table.' SET '; } else { @@ -131,11 +131,11 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + if ($low_priority) - $query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;'; + $query='DELETE LOW_PRIORITY QUICK FROM '.$table.' WHERE '.$where.' LIMIT 1;'; else - $query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;'; + $query='DELETE FROM '.$table.' WHERE '.$where.' LIMIT 1;'; if ($debug) $tdeb=microtime_float(); @@ -171,7 +171,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + $query="SELECT $fields FROM $table WHERE $where;"; if ($debug) $tdeb=microtime_float(); @@ -241,7 +241,12 @@ class WDB } else { $duree = 'N/D'; } - file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND); + if ($this->errorCode == 0) { + $msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; + } else { + $msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree; + } + file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND); } /** @@ -251,7 +256,7 @@ class WDB { $this->errorCode = 0; $this->errorMsg = ''; - + try { $stmt = $this->db->query($query); $this->result = $stmt; @@ -307,7 +312,7 @@ class WDB $nbLignes = count($res); for($i=0; $i<$nbLignes; $i++) { $ligne = $res[$i]; - + //Header if ($i==0) { $nbCols = count($ligne); @@ -317,7 +322,7 @@ class WDB } fputcsv($fp, $header, $sep, '"'); } - + //Content $fields = array(); foreach ($ligne as $libCol => $col) { @@ -325,7 +330,7 @@ class WDB } fputcsv($fp, $fields, $sep, '"'); } - + fclose($fp); return $nbLignes; }