model里MANY_MANY的问题

class Suit extends CActiveRecord

tablename ‘bank_suit’

class Topic extends CActiveRecord

tablename ‘bank_topic’

表suit和topic是多对多的关系。

class TopicBelongSuit extends CActiveRecord

tablename ‘bank_suit_topic’

	

<?php


class Suit extends CActiveRecord

{

	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(

			'topics'=>array(self::MANY_MANY, 'Topic', 'bank_suit_topic(sid,tid)',),

	

		);

	}




}



这里不能直接写TopicBelongSuit(sid,tid)? ??? ??? ???

必须是中间表名,不是类名。

我是想能不能做成写类名,而不是写中间表名

之所以采用表名,是因为中间表不一定有对应的AR class的。如果你想避免直接写表名,你可以调用PivotTable::model()->tableName()