" title="帐号设置" class="settings"></a> </div> <div class="profile-stats"> <a href="<?php echo Yii::app()->createUrl('album/myalbum'); ?> "><strong><?php echo $sl = Album::model()->countByAttributes(array('user_id' => Yii::app()->user->id)); ?> </strong>我的照片</a> <a href="<?php echo Yii::app()->createUrl('user/mystore'); ?> " class="middle"><strong><?php echo $count = Picshoucang::model()->countByAttributes(array('pic_uid' => Yii::app()->user->id)); ?> </strong>收藏</a> <a href="<?php echo Yii::app()->createUrl('follow', array('uid' => Yii::app()->user->id)); ?> "><strong><?php $byshui = Yii::app()->user->id; $fansnu = "select * from {{follow}} where touid={$byshui}"; $numFAN = count(Follow::model()->findAllBySql($fansnu)); echo $numFAN; ?> </strong>粉丝</a> </div>
?> "><img src="<?php echo $_p->album_img; ?> " /></a> <?php if (!Yii::app()->user->getIsGuest()) { ?> <?php //收藏与已经收藏判断,不能放在控制器中 $userid = Yii::app()->user->id; $picid = $_p->id; // 联合查询同时满足同一主键的数据,如果返回为NULL就是未收藏,否则一经收藏 $sql = "select * from {{picshoucang}} where pic_uid={$userid} and pic_id={$picid}"; $sc_sixiang = Picshoucang::model()->findAllBySql($sql); if ($sc_sixiang == NULL) { ?> <a href="<?php echo Yii::app()->createUrl('album/storepic', array('id' => $_p->id)); ?> " class="img_album_btn"><div>加入专辑</div></a> <?php } else { ?> <a class="img_album_btn"><div>已收藏</div></a> <?php } ?> <?php } else {
public function actionUnstore($id) { $model = Picshoucang::model()->findByPk($id); if ($model->delete()) { //添加成功时候的提示信息设置 /** *setFlash getFlash hasFlash 几个方法 */ Yii::app()->user->setFlash('unstore', '取消收藏成功 -_-!'); } $this->redirect('./index.php?r=user/mystore'); }
/** * This is invoked after the record is deleted.删除图片之后删除相应的内容 */ protected function afterDelete() { parent::afterDelete(); Picshoucang::model()->deleteAll('pic_id=' . $this->id); }
public function actionStorepic($id) { $model = new Picshoucang(); $model->pic_uid = Yii::app()->user->id; $model->pic_id = $id; $model->store_time = time(); $model->save(false); //Yii::app()->user->setFlash('picshoucang','美图收藏成功 ^_^ '); //完善一个我的收藏页面 //$this->redirect('./index.php?r=album'); $this->redirect_message('美图收藏成功!', 'success', '3', $this->createUrl('album/index')); }