我想只获取指定的字段,但是当我这样做时:
$criteria = new CDbCriteria();
$criteria->condition = 't.DeletionMark = 0';
$criteria->select = 't.Description, address.Description, city.Description';
$data = WCatalogInternetCounterparties::model()->with('internetCounterpartyAddresses.address.city')->findAll($criteria);
Active Record使用select Condition
中的所有字段生成查询答案 0 :(得分:0)
这是因为您使用的是Active Records,只能使用DAO获得所需的字段。
Yii::app()->db->createCommand()
->select('t.Description, address.Description, city.Description')
->where('t.DeletionMark = 0')
->from('w_catalog_internet_counterparties')
->with('internetCounterpartyAddresses.address.city')
->queryAll();