Reputation: 307
In my Yii application I have the model:
class Article extends ActiveRecord
{
public static function tableName()
{
return '{{article}}';
}
public static function getLatestArticles()
{
return parent::find()->where( 'TO_DAYS(NOW()) - TO_DAYS(published) <= 7
AND ISNULL(arch)')
->orderBy(
['DAYOFWEEK(published)' => SORT_DESC,
'rubric' => SORT_ASC,
])->all();
}
public function getArticlerubric()
{
return $this->hasOne(Rubric::class,['id' => 'rubric']);
}
What is the correct way to use the getLatestArticles() function : parent::find(), self::find() or static::find() ?
Upvotes: 0
Views: 42
Reputation: 387
static::find() would probably be the best bet, but self::find() should do the job.
Otherwise it's Article::find()
Upvotes: 1