Hi everyone,
First of all I’ve got to say that all my raltions in my models even MANY_MANY are working properly,so If I try to use $modelA->modelB… it works.
But I’m having problems using relations MANY_MANY in my search method with these models, e.g:
ModelA(restaurantes):
public function relations()
{
return array(
...
'servicios' => array(self::MANY_MANY, 'Servicios', 'serviciosrestaurantes(servicios_id,restaurantes_id)'),...
);
}
ModelB(servicios):
public function relations()
{
return array(
'serviciosRestaurantes' => array(self::HAS_MANY, 'ServiciosRestaurantes', 'servicios_id'),
);
}
And here a widget triying to use search method with these relationships:
$this->widget('bootstrap.widgets.TbThumbnails', array(
'id'=>'restaurantes-grid',
'dataProvider'=>$modelRst->search(array('condition'=>'servicios.id=1')),
'template'=>"{items}\n{pager}",
'itemView'=>'_rowRestaurante'
)
);
When I try this, I get the following error:
CDbCommand ... SQL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'servicios.id' in 'where clause'.
I’ve been checking the sql, and there aren’t inner joins of the MANY_MANY relationships, so obiously the column ‘servicios’ doesn’t exist.
And if I use
var_dump($modelA->modelB);
I get array(0) { }…
Help
PD:I’ve just realized that in :
public function search($param = array())
{...
I don’t have a
$criteria->with[]='model';
$criteria->addSearchCondition('',$this->),true);
for this MANY_MANY relationship…Could it be the problem?Is there an special addSearchCondition for this MANY_MANY relationships???