SAE MySQL connection instance (create a table)

Source: Internet
Author: User

Reprinted address

Access MySql in SAE

Sample Code:

$ Con = mysql_connect (sae_mysql_host_m. ':'. sae_mysql_port, sae_mysql_user, sae_mysql_pass );

Username: sae_mysql_user
Password: sae_mysql_pass
Master database Domain Name: sae_mysql_host_m
Slave database Domain Name: sae_mysql_host_s
Port: sae_mysql_port
Database Name: sae_mysql_db

Note: The create datebase operation cannot be performed in SAE.
In the MySQL database of SAE, only one database can be operated. The name is app _ (your application name)

My test code: (access the database and create a data table named persons)

$ Con = mysql_connect (sae_mysql_host_m. ':'. sae_mysql_port, sae_mysql_user, sae_mysql_pass );

Mysql_select_db ("app _ ***", $ con );
$ SQL = "CREATE TABLE persons (
Firstname varchar (15 ),
Lastname varchar (15 ),
Age int
)";
Mysql_query ($ SQL, $ con );
?>

<? PHP $ mysql = new saemysql (); $ SQL = "CREATE TABLE persons (firstname varchar (15), lastname varchar (15), age INT )"; $ mysql-> runsql ($ SQL); if ($ mysql-> errno ()! = 0) {die ("error:". $ mysql-> errmsg ();} echo "Table creation successful"; $ mysql-> closedb ();?>

Related Article

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.