PHP micro-Credit Public development notes (VI)

Source: Internet
Author: User
Tags add functions key key words new features php file query string
PHP micro-Credit Public Development Notes series
Date: 2014.9.4


Today, the main is to improve the search, joined the Administrator module, optimize the authentication, the Student information management package for a class (this is really very tired ah, the main database operation where the grammar is always a problem, has been a variety of small problems)


Feel:
PHP Development has no breakpoints, can not print log in time is really very tired ah (I was written with sublime, and then directly micro-letter public number debugging, I'm tired), error messages often can not be found in time, or some problems can be ruled out by a breakpoint could not be excluded. But it also shows that I am too sloppy to write code.

2014.9.10 to organize notes:
Write this note, in the rush function, so that is simply a few strokes of the work of the time, now the function developed almost, just to tidy up the previous notes.

In the Notes V I mentioned that some of the features that need to be implemented on the public platform are sorted by type: menus, databases are drawn out. The advantage of this is that in the future I do function adjustment or new features will not affect existing functions, conducive to development and maintenance.
In note four mentioned in the SAE I built a cloud database, and did a simple data retrieval function (in the menu-query menu to reply to the name, or learn number can get corresponding information), in the classmate's suggestion, need to find information quickly, So here I realized a function I call fast search: User reply name + telephone, name + home, name + address can get corresponding information; the realization of this function is also based on the retrieval of database and the monitoring of key words.

One, perfect search

In order to maintain convenience here, encapsulated a student information management class, that is, the previous reference to the database management of a package, because I was thinking that later may have more database requirements, later development and maintenance requirements will be higher; therefore, the current database processing of the relevant documents are:



1, student_info_sql.class.php is also the mysql_sae.func.php of a layer of packaging:

1 provides a statement on the operation of the database in mysql_sae.func.php, and the function accepts the relevant parameters <喎?http: www.2cto.com="" kf="" ware="" vc="" "="" target="_blank" class="keylink"> Vcd4kpha+pgltzybzcmm9 "/program/uploadpic/2014-9/ 201492512818624.png "alt=" >


2) and then I student_info_sql.class.php in the use of the process, passing the corresponding parameters in the past can be



And such a layer of packaging, I can guarantee that I can freely control the information that needs to be displayed, that is, I display student information and then control the display here, when I need to get a keyword and so on the data table, then I just need to create a corresponding PHP file, and then in the file control format can be;

Here's a reference to the Sae_log () function that appears in the above diagram, which is also wrapped by a print log that finds data on the Web:



The purpose of my packing is that if I don't need to print the log one day, I can just comment it out.
This student database management class also provides operations such as retrieving, adding, and so on. There is no need for extra notes here.

2, and then is referred to the optimization of data retrieval, that is, according to the needs of students---can quickly retrieve information, here is the key point is the keyword capture, here is used in PHP to the string-related processing function use:
Strstr (), str_replace () I mainly use these two; the first function is used to determine whether a particular character appears in a given string, and the second function is used for character substitution.

When the user sends a message over, I do this:



To deal with these three keywords, if the user sent over the message has these three keywords, and then with str_replace, the keyword replaced with empty, get the name, then there will be corresponding response operation. The check_userinfo shown in the above image is the one I used to do user authentication, menu_distribution_center the function that I mentioned before to organize the menu function, the menu is distributed. On the basis of independent encapsulation, I just need to capture the keyword, and then invoke the implementation of the Query menu related functions quickly achieved this function. function implementation is very simple, then encountered problems are mainly such as PHP syntax problems, database grammar problems, all kinds of pits, also embodies my this person sometimes careless, write code is too sloppy, there is no system of PHP has been learned, directly by writing code while learning, it will inevitably encounter a variety of problems.

Second, add the Administrator module
Because sometimes do not use the computer, and at this time need to operate such as database information updates and so on, how to do? I thought of it. Can implement an administrator function, under the conditions of authentication, you can send specific instructions to achieve the corresponding functions. The specific idea I realized was to encapsulate it into a class, a unified portal, and then authenticate. So I created a new file called admin_sys.class.php, encapsulated into a class, with a unified entrance, if I have new requirements, then I just need to add in this class can be, will not affect other system functions:

1, a unified entrance:



2, here the implementation of the authentication function and the previous implementation of user authentication similar, but also used to $_session information to save:



First of all to determine whether to verify the identity of the administrator, validated after the entry into the specific operational links, the specific operating environment is based on the corresponding instructions to operate. Here also do not mention, realize this administrator function is quite convenient, I can easily update the user information, add user information and so on.

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.