Thanks, it might be a good solution, but I have to specify the project id. So this will not work, unless there is a way to specify a project id too in that line of code.
I know about criteria, but I wanted to find the solution whithout creating CDbCriteria object.
I have temporary solved my problem by adding named scope:
$project = Project::model()->with('task:nomilestone')->findByPk($_GET['project_id']);
// in Task model:
public function scopes()
{
return array(
'nomilestone'=>array(
'condition'=>'REF_MILESTONE IS NULL',
),
);
}