wikipoints/ground/models/User.php

40 lines
689 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);
print_r($res['id']);
$user = $this->getByPK((int)$res['id']);
return $user;
}
else
{
return false;
}
}
function getPointsCount()
{
return Point::model()->getCountByUser($this->id);
}
}