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(
'categorie' => array(self::MANY_MANY, 'Categorie', 'CategoryAssignment(news,categoria)'),
);
}Vorrei che alla richiesta index.php?r=news/index&id=33, comparissero tutte quelle news che hanno la categoria 33. Non mi riesce =(.
Riesco a mostrare, per ogni News, i tags assegnati:
<?php if (count($data->categorie) > 0): ?>
<div align="right">
<b>tags:</b>
<?php foreach ($data->categorie as $item) : ?>
<?php echo $item->nome; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>Ho provato nel controller actionIndex delle News a fare questo:
public function actionIndex() {
$dataProvider = new CActiveDataProvider('News',array(
'criteria' => array (
'with' => 'categorie',
'condition' => 'categorie.id=3',
)
));
$this->render('index', array(
'dataProvider' => $dataProvider,
));
}Ma tutto quello che ottengo è questo:
Error 500 CDbCommand ha riportato un errore nell'esecuzione della query SQL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categorie.id' in 'where clause'
Qualcuno sa spiegarmi il perchè?

Help














