On the learning of web--PHP fuzzy query technology
①. 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,"".$keywords."",$row['username'//关键词高亮
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.