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