Trying to execute this query:
SELECT md.title, md.url
FROM MenuData md, Menu m
WHERE m.parent=0
AND m.menuType=1
AND md.menuID = m.id
ORDER BY m.sort ASC
Like below:
$criteria = new CDbCriteria();
$criteria->together = true;
$criteria->with = array('MenuData');
$criteria->compare("Menu.menuType", 1);
$criteria->compare("Menu.parent", 0);
$criteria->join = 'LEFT JOIN MenuData ON MenuData.menuID=Menu.id';
$criteria->order = '`Menu.sort` ASC';
$criteria->compare("MenuData.locale", $this->lang);
$results = Menu::model()->findAll($criteria);
Have both Menu and Menudata models. But getting following error:
Relation "MenuData" is not defined in active record class "Menu".
$criteria->with == join.
I assume you have a relation in your model menu.
And your criteria: