Question When Using "with" And "scopes"

I’ve been trying to use scopes inside the with option and haven’t been able to figure out how. Here’s an example setup similar to mine:

ParentModel has the following scopes




"getValidatedEntries" => array(

    "condition" = "valid = 1",

)



ChildModel belongs to ParentModel

I’m trying to use the scope like this:




$validChildModels = $childModel(array(

	'with' => array(

		'parentModel' => array(

			'scopes' => array(

				'getValidatedEntries',

			),

		),

	),

));



Doing it this way, I end up losing parentModel for some reason ($validChildModel->parentModel becomes null)

But if I run the code without using the scope like this




$validChildModels = $childModel(array(

	'with' => array(

		'parentModel' => array(

			'condition' = 'valid = 1',

		),

	),

));



it works fine. Any idea what I’m doing wrong?

I think you have do something as following




childModel::model()->with('parentModel:getValidatedEntries')->findAll()

Note: In case it does not work just double check the syntax

Hm, your request looks fine to me at the first look. I’d first check the resulting sql query you get.