Q:

Yii - activeRecord - with adds an automatic orderby clause

I try to find out why and where "orderBy" clause is added when I do a with (CDCriteria) but nothing on the Internet and unable to find in the code..
I have 3 tables defining place types (id, name for each):
Category > Activity > Specialty
I have a table place :
id | name | place_type_id | place_type_spe_id
I have several defined relations in Place model: 
public function relations() {
    return array(

        'placeType' => array(self::BELONGS_TO, 'PlaceType', 'place_type_id'),
        'placeTypeSpecialty' => array(self::BELONGS_TO, 'PlaceTypeSpecialty', 'place_type_specialty_id'),           
    );
}

Defined relations in PlaceType (actiivty) model :
  public function relations() {
    return array(           
        'places' => array(self::MANY_MANY, 'Place', 'place_secondary_type(place_type_id, place_id)'),
        'placeTypeCategory' => array(self::BELONGS_TO, 'PlaceTypeCategory', 'place_type_category_id'),
        'placeTypeSpecialties' => array(self::HAS_MANY, 'PlaceTypeSpecialty', 'place_type_id'),
    );

I would like to search keywords in place name, relative activity name, relative specialty name and relative category name (depending on activity..).
I tried : 
        $criteria = new CDbCriteria();
    $criteria->with = array('placeType', 'placeType.placeTypeSpecialties', 'placeType.placeTypeCategory');
    $criteria->together = true;

    $words = StringHelper::parseKeywords($keywords);

    $keywordsCriteria = new CDbCriteria();
    foreach ($words as $w) {
        $wordCriteria = new CDbCriteria();

        $wordCriteria->compare('t.name', $w, true, 'OR');
        $wordCriteria->compare('placeTypeCategory.name', $w, true, 'OR');
        $wordCriteria->compare('placeTypeCategory.expression', $w, true, 'OR');
        $wordCriteria->compare('placeType.name', $w, true, 'OR');
        $wordCriteria->compare('placeType.common_words', $w, true, 'OR');
        $wordCriteria->compare('placeTypeSpecialties.name', $w, true, 'OR');
        $keywordsCriteria->mergeWith($wordCriteria, 'OR');
    }

    $criteria->mergeWith($keywordsCriteria);

    $this->getDbCriteria()->mergeWith($criteria);
    return $this;

But... SQL query failed because of : 
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'name' in order clause is ambiguous.

And the ORDER BY clause is : 
ORDER BY distance ASC, placeType.name ASC, name ASC

"name" is obviously ambigous but I dont' want to order by this field ! Adding $criteria->with = array('placeType.placeTypeCategory'); adds this order by clause..
My questions are :
Why this is added and how to ignore it..
Thanks

A:

I found out the problem.
The previous developper has added, in PlaceTypeCategory model, a defaultScope function :
    public function defaultScope()
{
  return array(
    'order' => 'name ASC'
  );
}

I did not know this possibility.

