六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

一個容易的 MySQL 搜索函數使用案例

[摘要]$velocityCount怎么才能更好的學習MySQL,下面小編帶你們了結一個簡單的 MySQL 搜索函數。if (!function_exists(mysql_search)) {function mysql_search($table, $columns, $query = , $optio...

怎么才能更好的學習MySQL,下面小編帶你們了結一個簡單的 MySQL 搜索函數。

if (!function_exists('mysql_search')) {
   function mysql_search($table, $columns, $query = '', $options = Array()) {
      if (empty($query)) { return Array(); }
      $sql_query = Array();
      $options['columns'] = isset($options['columns'])?$options['columns']:'*';
      $options['method'] = isset($options['method'])?$options['method']:'OR';
      $options['extra_sql'] = isset($options['extra_sql'])?$options['extra_sql']:'';
      $query = ereg_replace('[[:<:]](and or the)[[:>:]]', '', $query);
      $query = ereg_replace(' +', ' ', trim(stripslashes($query)));
      $pattern = '/([[:alpha:]:]+)([[:alpha:] ]+)[[:alpha:]]?+[ ]?/i';
      $regs = Array();
      preg_match_all($pattern, $query, $regs);
      $query = $regs[0];
     while (list($key, $value) = @each($query)) {
        $column = $columns;
         $keywords = urldecode($value);
         if (strpos($value, ':')) {
            $column = substr($value, 0, strpos($value, ':'));
            $keywords = trim(substr($keywords, strpos($keywords, ':') + 1));
            $keywords = ereg_replace('\'', '', $keywords);
         } else { $keywords = ereg_replace(' +', ' ', $keywords); }
         $column_list = explode(' ', $column);
         $sql = Array();
         for ($i = 0; $i < count($column_list); $i++) { $sql[] = '' . $column_list[$i] . ' REGEXP "' . $keywords . '"'; }
         $query[$key] = Array('orignal'=>$value, 'sql'=>implode(' ' . $options['method'] . ' ', $sql));
         $sql_query = array_merge($sql_query, $sql);
         $sql_query = implode(' ' . $options['method'] . ' ', $sql_query);
      }
      $results = mysql_fetch_results(mysql_query('SELECT ' . $options['columns'] . ' FROM ' . $table . ' WHERE ' . $sql_query . ' ' . $options['extra_sql']));
      return $results;
   }

}

以上就是一個簡單的 MySQL 搜索函數使用實例的詳細內容,更多請關注php中文網其它相關文章!


學習教程快速掌握從入門到精通的SQL知識。




主站蜘蛛池模板: 污污视频在线播放 | 影音先锋国产 | 中文字幕在线免费观看视频 | 欧美亚洲国产专区在线app | 青娱乐国产 | 日本免费看片在线播放 | 亚洲视频在线播放 | 欧美一级纶理片免费 | 日本v片免费一区二区三区 日本vs欧美一区二区三区 | 日本不卡免费高清一级视频 | 夜夜揉揉日日人人视频 | 忘忧草一区 | 一级香蕉视频在线观看 | 日韩一级片免费观看 | 四虎免费在线观看 | 亚洲第一视频区 | 天堂网www| 视频一区二区三区在线观看 | 日韩特级 | 日本成人免费观看 | 伊人男人天堂 | 天堂bt| 天堂网在线资源 | 天堂网www在线资源链接 | 日本五级床片午夜视频 | 一二三四在线观看免费高清网 | 特级毛片黑人三人共一女 | 又粗又硬又大又爽免费视频播放 | 天堂a | 天天色天天射天天操 | 天天综合天天综合色在线 | 青草全福视在线 | 色综合综合网 | 青青青在线播放 | 天天做天天爱天天干 | 特级一级毛片 | 婷婷激情四月 | 欧美怡春院一区二区三区 | 一级毛片免费视频 | 五月天激情婷婷大综合 | 欧美特黄一级高清免费的香蕉 |