五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

mysql 全文檢索中文解決方法及實(shí)例代碼

發(fā)布日期:2022-08-02 11:34 | 文章來(lái)源:源碼之家

mysql 全文檢索中文解決方法

最近公司項(xiàng)目要求這樣的功能,在數(shù)據(jù)庫(kù)中檢索中文,很是棘手,上網(wǎng)查詢下資料,找的類似文章,這里及記錄下,希望能幫助到大家,

實(shí)例代碼:

<?php
/*
mysql全文檢索中文解決方案!
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', '1');
//數(shù)據(jù)庫(kù)支持
class SaeMysql{
//phpmysql操作類
}
$DBS=new SaeMysql;
//數(shù)據(jù)加入
echo '2';
/*創(chuàng)建數(shù)據(jù)表*/
$DBS->runSql('CREATE TABLE IF NOT EXISTS `ces_articles` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT \'\',
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `url` (`url`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC');
/*數(shù)據(jù)加入*/
$title='我愛(ài)大家啊,大家好';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
$title='中國(guó)是什么';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
$title='http://ask.1912news.com';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
$title='問(wèn)答系統(tǒng)';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
$title='1912網(wǎng)';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
$title='零九網(wǎng)絡(luò)';
$DBS->runSql('INSERT INTO `ces_articles` (id,title,url) VALUES (0,\''. $title.'\',\''.str_replace('\u','u',trim(json_encode($title))).'\')');
//搜索:
$_GET['q']="中國(guó)";
echo 'q';
if(isset($_GET['q'])){$sql=' match(url) against (\''.str_replace('\u','u',trim(json_encode($_GET['q']))).'\' IN BOOLEAN MODE)';}
$query = $DBS->getData('SELECT * FROM `ces_articles` where '.$sql.' LIMIT 10');
echo 'q';
if($query){
foreach ($query as $article){
echo $article['id'];
}
}
?>

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

海外服務(wù)器租用

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開(kāi)通

自選配置、實(shí)時(shí)開(kāi)通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問(wèn)服務(wù)

1對(duì)1客戶咨詢顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部