How To Create A Cactivedataprovider From A Model Realation?

I’ve a model ‘User’

User has this relation




'agency' => array(self::MANY_MANY, 'Agenzia', 'tbl_agenzia_utente(user_id, agency_id)'),



In the ‘view’ view of User I need to show a CActiveGrid with all associations beetween the current viewed user and all of its agency (it’s a many to many, like you can see)

I’m not able to understand how to create the CActiveDataProvider

Can you help me ?

Solved as is:




$visible_agency = new CActiveDataProvider('Agenzia', array (

			'criteria' => array (

				'with' 		=> array('users'),

				'condition' => "user_id = $id ",

				'together'  => true,

			),

		));