On the learning of web--PHP fuzzy query technology

Source: Internet
Author: User

①. Design for the database
If the password is MD5, use char (32), if it is half of the data, use char.
Gender, normal development is with Int.
Enter the criteria with default setting defaults
Key means adding an index to an index of the specified field CV
Index Benefits: If you follow a certain criteria to retrieve data, if there is no such criteria field is not indexed, when the query will traverse the entire table, if you set up an index, the query will be indexed to query, and thus improve query performance.

②.sql Matching pattern considerations
1. Use SQL match mode, cannot use operator = or! =
Instead, use the operator like or not to like
2, using SQL matching mode, MySQL provides 2 kinds of wildcard characters.
% (Percent semicolon): any number of characters
_ (Underscore): represents any single character
3, using the MySQL matching mode, if the matching format does not contain any of the above 2 wildcard characters,
Its query effect is equal to = or! =
4. Using SQL match mode is case insensitive by default

③.
wildcard character use;
0. case insensitive by default
1.% opening or ending%.
2.%% contains.
3._% a few openings or endings
3. Length _.

④ Regular expression-match character
. Match any single character
* Match 0 or more characters in front of it
A * indicates matching any number of a characters
[..] Any character that matches the brackets
[ABC] Match character a B or C
[A-z] matches any character
[0-9] Match any number
[0-9]* matches any number of any numbers
[a-z]* matches any number of any characters
^ denotes starting with a character or string
^a begins with the letter A
$ means ending with a character or string
a$ means ending with the letter A

⑤ operators used with regular expression matching patterns
1.regexp or not regexp; (rlike or not rlike)
If a regular expression is used to match, its pattern differs from SQL mode
SQL statement SELECT * from user where username REGEXP ' regular ';

The difference between regular expressions and SQL matching patterns

Get a field with a few characters, you need to add a start sign and a closing symbol, or there will be several wildcard characters. Just go back and judge that number.

error_reporting (0); block all errors. Development is not recommended to use, listed can be.

$row[‘username‘] = str_replace($keywords,"<font color=‘red‘>".$keywords."</font>",$row[‘username‘//关键词高亮

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

On the learning of web--PHP fuzzy query technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.