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 ();?>