예제 #1
0
파일: syn.php 프로젝트: lxthien/batdongsan
 function getProductComment($productId)
 {
     $comment = new Productcomment();
     $comment->where('product_id', $productId);
     $comment->order_by('creationDate', "asc");
     $comment->get_iterated();
     $dis3['comment'] = $comment;
     $dis3['base_url'] = base_url();
     return $this->load->view('front/product/product_comment', $dis3, TRUE);
 }
예제 #2
0
 function like_dislike($id)
 {
     $comment = new Productcomment();
     $type = $_POST['type'];
     $id = $_POST['id'];
     if (isset($_COOKIE['likeDislike' . "_" . $id])) {
         echo "error||Bạn đã bỏ phiếu cho bình luận này";
         exit;
     } else {
         if ($type == 'like') {
             $field_name = 'likes';
         } elseif ($type == 'dislike') {
             $field_name = 'dislikes';
         } else {
             die;
         }
         $comment->where('id', $id)->update($field_name, $field_name . ' + 1', false);
         //print_r($this->db->last_query());exit();
         $comment->get_where(array('id' => $id));
         // expired cookie is 30days
         $expire = time() + 60 * 60 * 24 * 30;
         setcookie("likeDislike" . "_" . $id, "likeDislike" . "_" . $id, $expire);
         echo "success||" . $comment->{$field_name};
         exit;
     }
 }