function getPage($page_number = 1) { if (!is_numeric($page_number)) { $page_number = 1; } $this->page_number = $page_number; $this->criteria->setOffset(($page_number - 1) * $this->items_per_page); $this->criteria->setLimit($this->items_per_page); return ORM::retrieve($this->criteria); }
private function _fetchI18n() { $primaryKey = $this->schema->getPrimaryKey()->name; // Grab the localized versions if present if ($this->hasI18n() && !$this->_i18n) { $c = new Criteria("{$this->model_name}_i18n"); $c->add("{$this->model_name}_{$primaryKey}", $this->{$primaryKey}); $i18n = ORM::retrieve($c); foreach ($i18n as $model) { $this->_i18n[$model->lang] = $model; } } }
static function retrieveByPrimaryKey($model_name, $primary_key_value) { $schema = self::getSchema($model_name); $primaryKey = $schema->getPrimaryKey(); if (!$primaryKey) { debug::error("ORM::retrieveByPrimaryKey error: no primary key defined for model <strong>{$model_name}</strong>."); } $c = new Criteria($model_name); $c->add($primaryKey->name, $primary_key_value); $c->setLimit(1); $instancies = ORM::retrieve($c); if (isset($instancies[0])) { return $instancies[0]; } else { return null; } }