aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-04-29 17:34:54 -0700
committerfriendica <info@friendica.com>2012-04-29 17:34:54 -0700
commite3fecb2557ad0ac2f156f9583683f7c9d998e212 (patch)
treefc357b10f27909b3a4170daaee147a2437b49505 /include/dba.php
parentdef6f0b408680c4e5f209890bbf1ad6bf40b5add (diff)
downloadvolse-hubzilla-e3fecb2557ad0ac2f156f9583683f7c9d998e212.tar.gz
volse-hubzilla-e3fecb2557ad0ac2f156f9583683f7c9d998e212.tar.bz2
volse-hubzilla-e3fecb2557ad0ac2f156f9583683f7c9d998e212.zip
improved db error logging
Diffstat (limited to 'include/dba.php')
-rw-r--r--include/dba.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/include/dba.php b/include/dba.php
index 44a663eac..414f4ae7a 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -74,23 +74,29 @@ class dba {
if((! $this->db) || (! $this->connected))
return false;
+
+ $this->error = '';
if($this->mysqli)
$result = @$this->db->query($sql);
else
$result = @mysql_query($sql,$this->db);
+ if($this->mysqli) {
+ if($this->db->errno)
+ $this->error = $this->db->error;
+ }
+ elseif(mysql_errno($this->db))
+ $this->error = mysql_error($this->db);
+
+ if(strlen($this->error)) {
+ logger('dba: ' . $this->error);
+ }
+
if($this->debug) {
$mesg = '';
- if($this->mysqli) {
- if($this->db->errno)
- logger('dba: ' . $this->db->error);
- }
- elseif(mysql_errno($this->db))
- logger('dba: ' . mysql_error($this->db));
-
if($result === false)
$mesg = 'false';
elseif($result === true)
@@ -102,7 +108,9 @@ class dba {
$mesg = mysql_num_rows($result) . ' results' . EOL;
}
- $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg . EOL;
+ $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg
+ . (($this->error) ? ' error: ' . $this->error : '')
+ . EOL;
logger('dba: ' . $str );
}
@@ -116,7 +124,7 @@ class dba {
if($result === false) {
logger('dba: ' . printable($sql) . ' returned false.');
if(file_exists('dbfail.out'))
- file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n", FILE_APPEND);
+ file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
}
if(($result === true) || ($result === false))