我的代码:
$criteria = new CDbCriteria();
// $criteria->select = array("id");
$criteria->with = array('userProfiles'=>array(
'select'=>'firstname'
));
$criteria->together = true;
$criteria->condition = "firstname like '%$q%' "
. "and (user_id not in (select id2 from friends where id1=$user_id) "
. "and user_id not in (select id1 from friends where id2=$user_id))";
$dataProvider = new CActiveDataProvider("Users", array(
'criteria' => $criteria
));
return $dataProvider;
笔记:
1-userProfiles
关系在用户模块中定义
问题:
尽管提供了选择属性,但它仅从 User 表而不是从 user_profiles 表加载数据'select'=>'firstname'
我想要来自user
和userProfile
表的数据。