Example #1
0
 public static function xflush()
 {
     if (self::$active) {
         #lib::el("flushing all cached objects");
         self::$cache = array();
     }
 }
Example #2
0
 public function _refresh()
 {
     $pk = $this->_t->pk;
     $id = $this->{$pk};
     _object_cache::forget(get_class($this), $id);
     $this->__virtmembers = array();
     $this->__members = array();
     $x = $this->_t->find_first($id);
     # this will give us a freshly created duplicate
     foreach ($this->_t->columns as $f => $c) {
         # copy all the fields from the dup to this
         $this->{$f} = $x->{$f};
     }
     _object_cache::forget(get_class($this), $id);
     # forget the singleton dup
     _object_cache::store(get_class($this), $id, $this);
     # store this
 }
 public function find($cond = NULL, $limit = NULL, $orderby = NULL)
 {
     if (empty($cond)) {
         return array();
     }
     if (!empty($limit) && !preg_match('/^\\d+(,\\d+)?$/', $limit)) {
         # FIXME report a better error here
         error_log("invalid limit {$limit}");
         return array();
     }
     list($where, $a) = $this->_conditions_to_query($cond);
     if (preg_match('/^\\s*select/', $where)) {
         $q = $where;
     } else {
         $q = "select " . $this->___collist() . " from " . $this->nameQ . " where {$where}";
     }
     if ($orderby) {
         $q .= " order by " . $orderby;
     }
     if ($limit) {
         $q .= " limit {$limit}";
     }
     $sth = $this->db->dbhandle->prepare($q);
     $sth->execute($a);
     #error_log($sth->_stmt());
     $r = array();
     $PK = $this->pk;
     $class = $this->modelname;
     while ($o = $sth->fetchrow_object($class)) {
         $o = _object_cache::singleton($o, $o->{$PK}, $class);
         $o->checkpoint();
         $r[] = $o;
     }
     return $r;
 }