Php Framework Development 4 (DAO layer) website development inevitably needs to store some data, but the methods for storing the data in various languages are basically: first open the connection, then execute the SQL statement to get the final result and close the connection. So what methods does PHP use to operate databases? & Lt ;? Php $ connectmysql_connect ($ host, $ user, $ pass); mysql_select_db ($ db php Framework Development 4 (DAO layer)
Website development inevitably needs to store some data, but the methods for storing the data in various languages are basically: first open the connection, then execute the SQL statement, get the result, and close the connection.
So what methods does PHP use to operate databases?
You can use the preceding operations to operate databases. This is enough for the industry that embeds PHP scripts in HTML, but when we want to add, delete, modify, and query a large number of requests, we must reuse the preceding scripts multiple times. This mode will appear.
DAO http://blog.csdn.net/tomyjohn/article/details/7675770
The above pattern is implemented as the DAO layer for the moment, but the real significance lies in our MVC framework, which can be used to operate. Next we will create a new controller
Title = 'title'; $ art-> content = 'content'; $ art-> save (); echo $ art-> id; view: show('index.htm ');}}
Create a new table named "si_article" in the database ",
DROP TABLE IF EXISTS `si_article`;CREATE TABLE `si_article` ( `id` int(8) NOT NULL AUTO_INCREMENT, `title` varchar(255) DEFAULT NULL, `content` text, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=gbk;
Create an "article. php" in the "modules" folder"
When we execute the controller above, we can see the ID of the newly inserted data.
In this way, we can easily implement an online message function.
Now, almost all MVC has been described. you can use it for development. of course, it is a complete but not rich MVC. There are still many things to consider. For example, paging, cache, and security. But this does not affect my love for this wheel.