Script | data | database | Detailed (author: Wang Kaibo)
use class to speed up PHP database development
database has more access functions, and improper use can reduce efficiency and even lead to errors. and PHP itself is open and extensible, many people for it to develop a variety of functional source code. Every PHP programmer should be good at inheriting the results of others and saving time and effort. Standing on the shoulders of giants to see farther. Of course, you can also share your code and experience the sense of accomplishment of your work being recognized and created value.
use of database classes allows us to focus on the development of a program without having to consider the specific database type at all.
a large number of development kits, Phplib is a more stable performance, the function of a more perfect one. Phplib can be obtained in http://phplib.netuse.de/. It contains the support classes for the database. Take the MySQL database as an example, Phplib with a class named Db_sql. It wraps the database connection, query, fetch result, database table traversal and so on function.
uses database classes, which allow us to focus on the development of the program without having to consider the specific database type at all. The program code does not have to change even if the database system type is changed. At the same time, database classes provide a complete and robust database access method, which may be the biggest advantage of using class wrappers.
below, we use the database class provided by Phplib to access the database we just created and display the content.
from the above process, we can see that the method of accessing the database by class is basically the same as that of accessing the database directly. The difference is that the method we call here is the method of the class, not the function specific to some kind of database. Because of the separation of the code and the specific database type, we do not need to change the program code when the database system changes, as long as we change the implementation method of the base class.
If you use the Phplib template to design, you can realize the separation between the program and the display. It will also make the structure of the program clear, Web page art design easy to make.
simple usage, reasonable task assignment, and thinking object packaging will make the website development efficiency greatly improved.
: Code test Platform
above program code all in the following platform test pass
RedHat Linux 6.1+apache1.3.12+
php4.0+mysql3.22.32
The installation configuration process for the
database is:
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.