wikipoints/models/Category.php

29 lines
562 B
PHP

<?php
class Category extends Model
{
private static $categories = NULL;
function __construct($fromArray = array())
{
$this->_tableName_ = 'categories';
parent::__construct($fromArray);
$this->setRelation('points', 'id', 'Point', 'categoryId', self::TO_MANY);
}
static function model()
{
return new self();
}
static function getIcoById($id)
{
if (self::$categories === NULL) {
self::$categories = self::model()->getAll(array('asArray'=>true));
}
return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL;
}
}