Jump to content
  • entries
    6
  • comments
    13
  • views
    1,184

Поиск по номеру телефона

Sign in to follow this  
SooR

1,048 views

Вариант поиска для тех, у кого нет форматирования телефонов перед добавлением их в базу.

Можно искать как заказы, так и покупателей, или чего-угодно, где есть это поле.

 

Пример для поиска заказов

if (!empty($data['filter_telephone'])) {
  $telephone = preg_replace('/\D+/', '', $data['filter_telephone']);

  $sql .= " AND (TRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(o.telephone, ' ', ''), '(', ''), ')', ''), '-', ''), '/', ''), '+', '')) LIKE '%" . $this->db->escape($telephone) . "%' OR " . $this->db->escape($telephone) . " LIKE CONCAT('%', TRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(o.telephone, ' ', ''), '(', ''), ')', ''), '-', ''), '/', ''), '+', '')), '%'))";
}

Какие номера находит: 

 

  • +38(050)123-45-67 
  • 501234567 
  • (050)123-45-67 
  • 050 123 45 67 
  • 0501234567 
  • (050)1234567

 

или любое вхождение в них.

  • +1 1
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Guest
You are posting as a guest. If you have an account, please sign in.
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.