Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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;
         }
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }