+
+ static function blow()
+ {
+ $c = self::memcache();
+
+ if (empty($c)) {
+ return false;
+ }
+
+ $args = func_get_args();
+
+ $format = array_shift($args);
+
+ $keyPart = vsprintf($format, $args);
+
+ $cacheKey = Cache::key($keyPart);
+
+ return $c->delete($cacheKey);
+ }
+
+ function fixupTimestamps()
+ {
+ // Fake up timestamp columns
+ $columns = $this->table();
+ foreach ($columns as $name => $type) {
+ if ($type & DB_DATAOBJECT_MYSQLTIMESTAMP) {
+ $this->$name = common_sql_now();
+ }
+ }
+ }
+
+ function debugDump()
+ {
+ common_debug("debugDump: " . common_log_objstring($this));
+ }
+
+ function raiseError($message, $type = null, $behaviour = null)
+ {
+ $id = get_class($this);
+ if (!empty($this->id)) {
+ $id .= ':' . $this->id;
+ }
+ if ($message instanceof PEAR_Error) {
+ $message = $message->getMessage();
+ }
+ // Low level exception. No need for i18n as discussed with Brion.
+ throw new ServerException("[$id] DB_DataObject error [$type]: $message");
+ }
+
+ static function cacheGet($keyPart)
+ {
+ $c = self::memcache();
+
+ if (empty($c)) {
+ return false;
+ }
+
+ $cacheKey = Cache::key($keyPart);
+
+ return $c->get($cacheKey);
+ }
+
+ static function cacheSet($keyPart, $value, $flag=null, $expiry=null)
+ {
+ $c = self::memcache();
+
+ if (empty($c)) {
+ return false;
+ }
+
+ $cacheKey = Cache::key($keyPart);
+
+ return $c->set($cacheKey, $value, $flag, $expiry);
+ }
+
+ static function valueString($v)
+ {
+ $vstr = null;
+ if (is_object($v) && $v instanceof DB_DataObject_Cast) {
+ switch ($v->type) {
+ case 'date':
+ $vstr = $v->year . '-' . $v->month . '-' . $v->day;
+ break;
+ case 'blob':
+ case 'string':
+ case 'sql':
+ case 'datetime':
+ case 'time':
+ // Low level exception. No need for i18n as discussed with Brion.
+ throw new ServerException("Unhandled DB_DataObject_Cast type passed as cacheKey value: '$v->type'");
+ break;
+ default:
+ // Low level exception. No need for i18n as discussed with Brion.
+ throw new ServerException("Unknown DB_DataObject_Cast type passed as cacheKey value: '$v->type'");
+ break;
+ }
+ } else {
+ $vstr = strval($v);
+ }
+ return $vstr;
+ }