?> </a></b><span style="float:right; font-size: 10px;margin-right:3px;"><?php echo $this->checkTime($p->date); ?> </span><br /> <?php echo $p->message; ?> </td> </tr> <tr> <td> </td> <td> </td> <td> <?php $like = LikePost::model()->find('post_id=:post_id AND user_id=:user_id', array('post_id' => $p->id, 'user_id' => Yii::app()->user->userId)); if (!$like) { ?> <span id="like_<?php echo $p->id; ?> "><i class="icon-check"></i><a href="javascript:void(0)" onclick="postLike(<?php echo $p->id; ?> )">LIKE</a></span> <?php } else { ?> <span id="like_<?php echo $p->id; ?>
public function actionpostdelete($postId) { $model = Post::model()->find('id=:id', array('id' => $postId)); $comments = CommentPost::model()->findAll('post_id=:id', array('id' => $postId)); $likes = LikePost::model()->findAll('post_id=:id', array('id' => $postId)); foreach ($comments as $c) { $c->delete(); } foreach ($likes as $l) { $l->delete(); } $model->delete(); echo "success"; }