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; }