Model Self Relation Search

Controller:




    $criteria=new CDbCriteria;

    $criteria->compare('miembro.nombre','Ricardo',true);

    $criteria->with=array(

            'miembro'

        );

    $criteria->together = true;

    $m = Miembro::model()->findAll($criteria);



$m return Array Empty :(

Model Miembro.php:




public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'miembro' => array(self::HAS_ONE, 'Miembro', 'id_escuela'),

		);

	}



I hope someone can help me…

Thx! :)

Did you check to sql query log to see what actual query is generated by the criteria?

You was right!

I changed my code by:

Controller:


$criteria=new CDbCriteria;

    $criteria->compare('miembro.nombre','Lorena',true);

    $criteria->with=array(

            'escuela',

            'miembro'=>array('alias'=>'t2','join'=>'LEFT JOIN `miembro` `miembro` ON (`miembro`.`id_escuela`=`t`.`id_escuela`) ')

        );

    $criteria->together = true;

    $m = Miembro::model()->findAll($criteria);

Thanks so much! :D

maybe HAS_ONE --> BELONGS_TO ?