39 lines
665 B
PHP
39 lines
665 B
PHP
<?php
|
|
|
|
class User extends Model
|
|
{
|
|
function __construct($fromArray = array())
|
|
{
|
|
$this->_tableName_ = 'users';
|
|
parent::__construct($fromArray);
|
|
$this->setRelation('category', 'catogoryId', 'Category', 'id', self::TO_ONE);
|
|
}
|
|
|
|
static function model()
|
|
{
|
|
return new self();
|
|
}
|
|
|
|
function getByUID($uid)
|
|
{
|
|
$res = App::DB()->query('SELECT `id` FROM `' . $this->_tableName_ . '` WHERE `uid` = "' . $uid . '"');
|
|
if ($res)
|
|
{
|
|
$res = $res->fetch(PDO::FETCH_ASSOC);
|
|
$user = $this->getByPK((int)$res['id']);
|
|
|
|
return $user;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function getPointsCount()
|
|
{
|
|
return Point::model()->getCountByUser($this->id);
|
|
}
|
|
}
|
|
|