summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
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')));
}