summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlezvous.ca>2008-06-22 10:09:41 -0400
committerEvan Prodromou <evan@controlezvous.ca>2008-06-22 10:09:41 -0400
commit745a145f0dacc0ef04a43157887d322bf37225eb (patch)
tree746dfe035888818360c90b5111a2002b671f6ee3 /lib/util.php
parent676bbebe1a6225d77416a0e3ea57a90b25627ced (diff)
add better debugging
darcs-hash:20080622140941-34904-2a0eda21f6a374a9d26107a4bc627fc6de2a7063.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php19
1 files changed, 19 insertions, 0 deletions
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')));
}