【发布时间】:2019-11-09 21:03:42
【问题描述】:
我使用php从mysql数据库发送和接收数据 我的查询是
SELECT
*
FROM (
SELECT
*
FROM
test
WHERE
MATCH(word) AGAINST('+hello ')
) AS fulltext_scan
WHERE
fulltext_scan.word REGEXP '^hello '
当我搜索英文单词时,它运行良好 但是当我搜索 swedish(ä,ö,å) 单词时,我得到了这个错误
Got error 'nothing to repeat at offset 1' from regexp
我的连接中有array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'") 和header('Content-Type: text/html; charset=utf-8');
当我直接从 phpmyadmin 测试查询时,即使使用瑞典语单词也能正常工作
我想使用AS 进行排序
SELECT pages.*, MATCH (head, body) AGAINST ('some words') AS
AND column REGEXP '^hello ' relevance,
MATCH (head) AGAINST ('some words') AS title_relevance
FROM pages
WHERE MATCH (head, body) AGAINST ('some words')
ORDER BY title_relevance DESC, relevance DESC
先得到 {hello}
如何在我的 php 页面中解决这个问题?
【问题讨论】:
-
@WiktorStribiżew 但查询直接在 phpmyadmin 上运行
-
可能是
fulltext_scan.word like 'hello %'? -
@WiktorStribiżew:你什么意思?
-
你能提供一个带有瑞典字符的示例字符串吗?
-
当我搜索“hello”时,代码在我的 php 页面中工作,但是当我搜索“ögon”时,我得到了错误
标签: php mysql regex full-text-search