在我的网站上,我整合了一个搜索。我尝试过全文搜索,但它并不像我想的那样不区分大小写。艺术家和歌曲在MySQL的不同栏目中。
代码是:
public function search($query, $page_num = 1, $cid=null) {
if (empty($page_num)) $page_num = 1;
$items = $this->db->get_results('SELECT added, store.id, categories.id AS category_id, categories.name AS category_name, artist, song, file, size, youtube_url, downloads, hits
FROM store LEFT JOIN categories ON (store.cid = categories.id)
WHERE MATCH(artist, song, added) AGAINST ("+' . $this->db->escape($query) . '" IN BOOLEAN MODE)
'. ($cid!==null ? ' AND store.cid = "'.intval($cid).'"' : '') .'
ORDER BY added DESC
LIMIT ' . ($page_num - 1) * SONGS_ON_PAGE . ', ' . SONGS_ON_PAGE, ARRAY_A);
答案 0 :(得分:-1)
您可以从以下查询中返回结果:
SELECT * FROM store
WHERE CONCAT(artist, song) LIKE '%<search>%'