Multiple MANY_MANY relations

Ok so i have two models:

1: pv_array (photovoltaic array)

2: module (photovoltaic module)

there is a MANY_MANY relation between both of them:

		return array(		

			'modules' => array(self::MANY_MANY, 'module', 'module_to_array(array_id, module_id)'),


		return array(

			'arrays' => array(self::MANY_MANY, 'pv_array', 'module_to_array(module_id, array_id)'),


The problem is when i add modules to an array i need the ability to add multiple instances of the same module to an array… i can do this no problem, when i check the Database table module_to_array there are multiple entries present.

Although when i now go to access the modules in the array as follows:

$pv_array = pv_array::model()->findByPk( 2 );

echo count( $pv_array->modules);

it only counts single instances of modules and not the multiple instances of modules as are present…??

for example if i added 3 x ModuleXYZ and 2x ModuleABC to Array1 i would only get the following

echo count( $Array1->modules ); // would echo 2

where i would want it to echo 5

any idea?

Try adding ‘select’=>’ ’ into your relation to achieve the results.

Will that not be default to ‘*’ all fields?. I may be wrong but i don’t think a select statement will suffice in this circumstance.

Is there a way to view the current query that is being executed in these relations?