//能否在HAS_MANY属性下增加一个as_fields属性,使其查询结果成这样,请仔细看代码。
protected $_link = array(
'profile'=>array(
'mapping_type' =>HAS_MANY,
'class_name' =>'Profile',
'foreign_key'=>'userId',
'as_fields'=>'count(Id) as pcount',//注意这里,是我自己想象的功能,实际并没有该功能
),
);
//查询的结果就变成了下面的结果
array(
'id' => 1,
'account' => 'ThinkPHP',
'password' => 'name',
'pcount' =>'22',//一共查询到22条Profile记录。
) 