31 lines
505 B
PHP
31 lines
505 B
PHP
<?php
|
|
|
|
class ArticlePhotos extends Model
|
|
{
|
|
|
|
function __construct($fromArray = array())
|
|
{
|
|
$this->_tableName_ = 'articlePhotos';
|
|
parent::__construct($fromArray);
|
|
$this->setRelation('authorUser', 'owner', 'User', 'id', self::TO_ONE);
|
|
}
|
|
|
|
static function model()
|
|
{
|
|
return new self();
|
|
}
|
|
|
|
function getByUser($userId, $limit = 0)
|
|
{
|
|
$params = array(
|
|
'where' => '`owner` = '.(int)$userId,
|
|
);
|
|
|
|
if ($limit > 0) {
|
|
$params['limit'] = (int) $limit;
|
|
}
|
|
|
|
return $this->getAll($params);
|
|
}
|
|
}
|