newLike new ArticlesLikes newLike- id_article id newLike- id_user CUse

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$newLike = new ArticlesLikes;
$newLike->id_article = $id;
//$newLike->id_user = CUserIdentity::getId(); //FIXME Получить айди текущего юзера!
$newLike->id_user = Yii::app()->user->getId(); //FIXME Получить айди текущего юзера!
$newLike->id_tag = (int)($_POST['idTagLiked']);
$likes = ArticlesLikes::model()->findByAttributes(
array('id_article'=>$newLike->id_article , 'id_tag'=>$newLike->id_tag , 'id_user'=>$newLike->id_user )
);
if(count($likes)=0)
if($newLike->save()){
$newLikeChek=ArticlesLikes::model()->findAll();
}