application/models/mobile_api/Common_model.php
/* Insert  the comments of shortlisted property with perticular roomType into commentRead table*/
Insert  the comments of shortlisted property with perticular roomType into commentRead table
Insert the comments of shortlisted property with perticular roomType into commentRead table
public function shortlisted_property_comments_read($post_data){
        $searchId = $post_data['searchId'];
        $shortlistedId = $post_data['shortlistedId'];
        $roomType = $post_data['roomType'];
		$roomType = $roomType;
        $loginUserId = $post_data['loginUserId'];
        if($roomType == 'ALL'){
            $roomType = '';
        } else{
           $roomType = 'AND c.roomType ="'.$roomType.'"';
        } 
        $sql = "SELECT c.*,cr.userId as readUserId,cr.commentId as readCommentId,cr.shortlistedId as readShortlistedId,cr.roomType as readRoomType,u.firstName,u.lastName FROM comments c 
            LEFT JOIN commentsread cr ON cr.shortlistedId = c.shortlistedId AND cr.userId = $loginUserId AND c.commentId = cr.commentId
            LEFT JOIN users u ON u.userId = c.userId
            WHERE c.shortlistedId = $shortlistedId AND c.searchId =$searchId $roomType AND c.deleteFlag !=1";
        $record = $this->db->query($sql);
        if($record->num_rows()>0){
            $data = $record->result_array();
            $insert_data = array();
            foreach ($data as $detail) {
               if(!$detail['readUserId']){
                  $readdata = array(
                                    'userId' => $loginUserId,
                                    'commentId' => $detail['commentId'] ,
                                    'shortlistedId' => $detail['shortlistedId'],
                                    'roomType' => $detail['roomType'],
                                    'readFlag' => 1
                                );
                  $insert_data[] = $readdata;
               }
            }
            if(count($insert_data)>0){
               return $this->db->insert_batch('commentsread', $insert_data); 
            }else{
                return true;
            }
        }else{
                return false;
            }
    }
public function shortlisted_property_comments_read ( $ post_data ) { $ searchId = $ post_data [ 'searchId' ] ; $ shortlistedId = $ post_data [ 'shortlistedId' ] ; $ roomType = $ post_data [ 'roomType' ] ; $ roomType = $ roomType ; $ loginUserId = $ post_data [ 'loginUserId' ] ; if ( $ roomType == 'ALL' ) { $ roomType = '' ; } else { $ roomType = 'AND c.roomType ="' . $ roomType . '"' ; } $ sql = " SELECT c.*,cr.userId as readUserId,cr.commentId as readCommentId,cr.shortlistedId as readShortlistedId,cr.roomType as readRoomType,u.firstName,u.lastName FROM comments c 
            LEFT JOIN commentsread cr ON cr.shortlistedId = c.shortlistedId AND cr.userId =  $ loginUserId  AND c.commentId = cr.commentId
            LEFT JOIN users u ON u.userId = c.userId

            WHERE c.shortlistedId =  $ shortlistedId  AND c.searchId = $ searchId $ roomType  AND c.deleteFlag !=1 " ; $ record = $ this -> db -> query ( $ sql ) ; if ( $ record -> num_rows ( ) > 0 ) { $ data = $ record -> result_array ( ) ; $ insert_data = array ( ) ; foreach ( $ data as $ detail ) { if ( ! $ detail [ 'readUserId' ] ) { $ readdata = array ( 'userId' => $ loginUserId , 'commentId' => $ detail [ 'commentId' ] , 'shortlistedId' => $ detail [ 'shortlistedId' ] , 'roomType' => $ detail [ 'roomType' ] , 'readFlag' => 1 ) ; $ insert_data [ ] = $ readdata ; } } if ( count ( $ insert_data ) > 0 ) { return $ this -> db -> insert_batch ( 'commentsread' , $ insert_data ) ; } else { return true ; } } else { return false ; } }
Insert  the comments of shortlisted property with perticular roomType into commentRead table
Insert the comments of shortlisted property with perticular roomType into commentRead table
//$roomType = "'".$roomType."'"; // $sql = "SELECT c.* FROM comments c WHERE c.shortlistedId = $shortlistedId AND c.searchId =$searchId AND c.roomType ='".$roomType."' AND c.deleteFlag !=1"; // echo $sql;exit(); //print_r($detail);exit(); //foreach