Ceelog 2012-06-02 17:21:45 3999次浏览 4条回复 0 0 0

三个表 [Product]--[userproduct]--[User]

[Product]为物品信息,包含作者uid字段 [user-product]为用户对物品的操作统计,如顶、踩、喜欢 [User]为用户表

现在要分页显示用户喜欢的物品,高手帮帮忙!

我的代码

User 模型加了 'likes'=>array( self::MANY_MANY, 'Product', '{{userproduct}}( uid, pid )')

执行

$uid = (int)( $_GET['uid'] );
$user = User::model()->findByPk( $uid );
if( $user ){
    print_r($user->likes);
}

时报错

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'likes_likes. uid' in 'on clause'. The SQL statement executed was: SELECT `likes`.`pid` AS `t1_c0`, `likes`.`uid` AS `t1_c1`, `likes`.`title` AS `t1_c2`, `likes`.`price` AS `t1_c3`, `likes`.`poster` AS `t1_c4`, `likes`.`thumb_poster` AS `t1_c5`, `likes`.`tiny_poster` AS `t1_c6`, `likes`.`postdate` AS `t1_c7`, `likes`.`isshow` AS `t1_c8`, `likes`.`catalog_id` AS `t1_c9`, `likes`.`description` AS `t1_c10`, `likes`.`type` AS `t1_c11` FROM `buyinfo_product` `likes` INNER JOIN `buyinfo_userproduct` `likes_likes` ON (`likes_likes`.` uid`=:ypl0) AND (`likes`.`pid`=`likes_likes`.`pid `)

怎么办?

您需要登录后才可以回复。登录 | 立即注册