如何将用户输入从搜索字段转换为特定的MySQL查询?

时间:2018-04-01 21:35:37

标签: mysql search mysqli

我的问题很简单,但我找不到答案。

如何在搜索字段中以两个或多个单词的形状(由特殊字符分隔)将用户输入的PHP搜索转换为特定的MySQL搜索查询?我将尝试通过例子来解释。

示例1:

用户输入:Caused by: org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/accountbalance/exp]; nested exception is org.springframework.web.client.HttpClientErrorException: 406 null at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:409) ~[spring-integration-http-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE] at com.bhargo.Main.run(Main.java:51) [classes/:na] 并发送一个查询,其中两个字都被搜索为短语(word1 + word2)(类似Google中的双引号搜索)

示例2:

用户输入:"word1 word2"并发送一个查询,其中两个单词被连续搜索,在word1 - word2word1 word2之间有0个或更多单词,但没有{{1} }或word1 word(n) word2

示例3:

用户输入:word2 word1并发送查询并仅从字符串以word2 word(n) word2开头的数据库单元格中获取结果。

还有更多的例子(上面的组合,搜索的词数更多),但如果我得到这些的帮助,我想我会弄明白其余的。

0 个答案:

没有答案