From 745a145f0dacc0ef04a43157887d322bf37225eb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 22 Jun 2008 10:09:41 -0400 Subject: add better debugging darcs-hash:20080622140941-34904-2a0eda21f6a374a9d26107a4bc627fc6de2a7063.gz --- lib/util.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index ae6752653..11b1bfd5e 100644 --- a/lib/util.php +++ b/lib/util.php @@ -762,6 +762,25 @@ function common_debug($msg, $filename=NULL) { } } +function common_log_db_error($object, $verb, $filename=NULL) { + $objstr = common_log_objstring($ojbect); + $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); + common_log(LOG_ERROR, $last_error->message . '(' . $verb . ' on ' . $objstr . ')', $filename); +} + +function common_log_objstring($object) { + if (is_null($object)) { + return "NULL"; + } + $arr = $object->toArray(); + $fields = array(); + foreach ($arr as $k => $v) { + $fields[] = "$k='$v'"; + } + $ojbstring = $object->tableName() . '[' . implode(',', $fields) . ']'; + return $objstring; +} + function common_valid_http_url($url) { return Validate::uri($url, array('allowed_schemes' => array('http', 'https'))); } -- cgit v1.2.3-54-g00ecf