Hi, I have a table notices with the following cols: id, name, id_templates, active, emails id_templates belongs to templates.id. This is set in the model this way:
$this->belongsTo(
'id_templates',
'Templates',
'id',
array(
'alias' => 'template'
)
);
Now I want to make this query:
Notices::find(array("columns" => "name, Templates.name, active, emails"));
But it returns this error:
Phalcon\Mvc\Model\Exception: Unknown model or alias 'Template' (11), when preparing: SELECT name, Template.name, active FROM [Notices]
And if I do it with the query method it returns ok:
self::query()
->columns("Notices.id as id, Notices.name as name, Templates.name as template, Notices.active as active")
->leftJoin("Templates")
->leftJoin("Reports")
->leftJoin("NoticesConf")
->order("name ASC")
->execute()
I have to do it with the Find method because I override it in a ModelBase, or the ability to override the query function an add it into a ModelBase a $start(microtime) / query / $end(microtime)