Write mysql_insert.log in the LOG_PATH

This commit is contained in:
Michael RICOIS 2012-07-16 10:11:49 +00:00
parent 3fd89eecae
commit 0c95998c22

View File

@ -20,7 +20,7 @@ class WDB {
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
else $this->database=$database;
$this->con_id = mysql_pconnect($this->host, $this->user,
$this->con_id = mysql_pconnect($this->host, $this->user,
$this->password);
if (!($this->con_id === false)) {
if (mysql_select_db($this->database, $this->con_id) === false) {
@ -29,7 +29,7 @@ $this->password);
die();
}
}
return mysql_query("SET NAMES 'latin1';", $this->con_id);
return mysql_query("SET NAMES 'latin1';", $this->con_id);
}
public function setCharSet($charSet) {
@ -69,7 +69,7 @@ public function insert($table, $toAdd, $debug=false, $low_priority=false){
$res=mysql_insert_id();
else
$res=true;
}
}
if ($debug) $this->trace($query, $res, $tdeb);
return $res;
}
@ -135,17 +135,17 @@ public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH,
return $tab;
} else {
$nbRows=mysql_num_rows($this->result);
if ($debug) $this->trace($query, $nbRows, $tdeb);
if ($debug) $this->trace($query, $nbRows, $tdeb);
return $nbRows;
}
}
public function fetch($assoc=MYSQL_BOTH) {
return mysql_fetch_array($this->result, $assoc);
return mysql_fetch_array($this->result, $assoc);
}
public function trace($query, $res='', $tdeb=-1) {
if (!$fp=fopen('mysql_insert.log', 'a'))
if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
return false;
$errnum=mysql_errno($this->con_id);
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
@ -214,7 +214,7 @@ public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL) {
}
$c=0;
foreach ($ligne as $libCol=>$col) {
$c++;
$c++;
if ($c<$nbCols) fwrite($fp, str_replace($sep,' ', $col).$sep);
else fwrite($fp, str_replace($sep,' ', $col));
}