Function สำหรับ Gen sql link

PHP Result Center PHP Result Center เป็นหมวด ที่ไว้รวบรวม โปรแกรม Code php Javascript CSS CMS

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Function สำหรับ Gen sql link

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

Function สำหรับ Gen sql link

โค้ด: เลือกทั้งหมด

    function buil_sql_like($text, $limit = 3) {
        global $db;
        $sql_like = '';
        $i = 0;
        $text = str_replace(array('_', '%'), array("\_", "\%"), $text);
        $text = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $text);
        $text = explode(' ', trim(preg_replace('`[\s]+`', ' ', $text)));
        if ( !empty($text) ) {
            foreach ($text as $word) {
                $word = $db->sql_escape(trim($word));
                $sql_like .= empty($sql_like) ? " LIKE '%$word%'" : " OR  '%$word%'";
                $i++;
                if ($i >= $limit) {
                    return $sql_like;
                }
            }
        }
        return $sql_like;
    } 
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 66