$eCond=($key!=count($data['contacts'])-1)?' OR ':'';
if(strlen($number)>10){
$phNumbers.=" phone LIKE '%".substr($number,strlen($number)-10)."' ".$eCond;
if(strlen($number)>9){
$phNumbers.=" phone LIKE '%".substr($number,strlen($number)-9)."' ".$eCond;
}else{
$phNumbers.=" phone LIKE '%".$number."' ".$eCond;
}
}
$result=$this->db->query("SELECT name,phone,profile_image FROM customer WHERE (".$phNumbers.") AND customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))");
$result=$this->db->query("SELECT customer_id,name,phone,profile_image FROM customer WHERE (".$phNumbers.") AND customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))");