In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to implement database operation in the development of Wechat public platform. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Train of thought analysis
Baidu developer Center provides powerful cloud databases (including MySQL, MongoDB, Redis). In this tutorial, we will demonstrate the operation of the familiar MySQL database to achieve the interaction between Wechat and the database.
It is very simple to use cloud database in BAE applications. The name in the database list is the dbname when connecting to the database. The user name, password, connection address, and port are taken out through the environment variable in the application.
The database can be accessed using standard PHP Mysql or PHP Mysqli extensions, which are available in BAE's PHP and can be used directly by applications.
For official documentation, please refer to: ttp://developer.baidu.com/wiki/index.php?title=docs/cplat/rt/mysql
Create a BAE MySQL database
3.1 Log in to Baidu developer Center-> Administration Center-> Select applications-> Cloud Environment-> Service Management-> MySQL (Cloud Database)-> create a database
3.2 create a database
Note: each application has and only one database enjoys a 1G free quota, while the rest of the database does not enjoy a free quota discount. You can use this offer again only if you delete the database that has already used the free quota.
3.3 created successfully
Here you can see the name of the database, that is, dbname, which will be used later.
Click "phpMyadmin" to access the database.
3.4 phpMyadmin interface
Create a new data table, enter the table name and the number of fields, and click "execute" to create the table.
3.5 create a table
Enter the field name and field type, and then click "Save" below to complete the creation of the table.
3.6 creation completed
Modify the id field as the primary key and add AUTO_INCREMENT; to make the from_user field unique (UNIQUE) to complete the modification of the table.
The table creation operation can also be done using the following SQL statement:
CREATE TABLE IF NOT EXISTS `test_ mysql` (`id` int (11) NOT NULL AUTO_INCREMENT, `from_ user` varchar (40) DEFAULT NULL, `passt` varchar (40) DEFAULT NULL, `password` varchar (40) DEFAULT NULL, `update_ time` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `from_ user` (`from_ user`))
PhpMyAdmin operation
This is the end of the creation of the database and data table. The following code will be written to explain in detail the use of the database and data table.
Official example (PHP MySQL)
An example of demo (PHP MySQL) officially provided by BAE is as follows:
Mysql/basic.php file content
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.