Hello all,
I have a little question, i want to use the find function of the model, but i have one little problem. When i try to order by a related model then i become this error here
Unknown model or alias 'Students\\Model\\Commentcurrent' (1), when preparing: SELECT [Students\\Model\\Blogpost].* FROM [Students\\Model\\Blogpost]
The code that i use looks like that at the moment
//Blogpost.php
/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSource('mBlogpost');
$this->hasOne('id', 'Students\Model\Commentcurrent','tableid', array('alias' => 'Commentcurrent'));
}
public function getArticles($limit) {
$artciles = self::find(array('title LIKE :lang: AND site = :site: AND visible = :visible:',
'bind' => array(
'lang' => '%{'.$lang.'}%',
'visible' => 1,
'site' => 'local.dev',
),
'limit' => $limit,
'order' => 'Students\Model\Commentcurrent.numcomments desc'
));
}
//Commentcurrent.php
/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSource('mCommentcurrent');
$this->hasOne('tableid', 'Students\Model\Blogpost', 'id', array('alias' => 'Blogpost'));
}
Thank you for your help :)