The following describes how to use Bae to connect to MySQL. The basic call is the same as the related MySQL functions of PHP:
Mysql_query-send a MySQL Query
Mysql_fetch_array-get a row from the result set as an associated array, or number array, or both
Mysql_fetch_row-retrieve a row from the result set as an enumerated Array
Mysql_fetch_assoc-get a row from the result set as the associated array
Mysql_result-get result data
Tutorial Manual: Click to View Details
<? PHP/* Bae database connected to the Wang Hai lab * // * obtain the name of the database to be connected from the platform */$ dbname = 'civsxiiejixqjrutnrme '; /* obtain the database connection parameters from the environment variables */$ host = getenv ('HTTP _ bae_env_addr_ SQL _ip '); $ Port = getenv ('HTTP _ bae_env_addr_ SQL _port '); $ user = getenv ('HTTP _ bae_env_ak '); $ Pwd = getenv ('HTTP _ bae_env_sk');/* Then call mysql_connect () connect to the server */$ link = @ mysql_connect ("{$ host }:{ $ port}", $ user, $ PWD, true); If (! $ Link) {die ("Connect server failed :". mysql_error ($ link);}/* Call mysql_select_db () immediately after successful connection to select the database to be connected */If (! Mysql_select_db ($ dbname, $ link) {die ("select database failed :". mysql_error ($ link);}/* the connection has been fully established, other standard PHP MySQL functions can be used for Database Operations */$ SQL = "select * From 'users' limit 0, 30 ;"; // $ SQL = "insert into 'users' ('name', 'email ', 'age', 'sex') values ('test01', 'test @ sina.cn ', '12', '1'); "; $ result = mysql_query (" $ SQL ") or die (" invalid query :". mysql_error (); While ($ ROW = mysql_fetch_assoc ($ result) {PR Int_r ($ row);} echo "that's all! ";?>
The following are the connection methods of SAE, many of which have been encapsulated. You can directly use SQL statements:
<? PHP $ mysql = new saemysql (); // query $ SQL = "select * From 'user' limit 10"; $ DATA = $ mysql-> getdata ($ SQL ); $ name = strip_tags ($ _ request ['name']); $ age = intval ($ _ request ['age']); // insert $ SQL = "insert into 'user' ('name', 'age', 'regtime') values ('". $ mysql-> escape ($ name ). "','". intval ($ age ). "', now ()"; $ mysql-> runsql ($ SQL); if ($ mysql-> errno ()! = 0) {die ("error:". $ mysql-> errmsg () ;}$ mysql-> closedb () ;?>
When you connect to phpadmin, if you haven't performed the operation for a long time, the page will be prompted to expire. Press Ctrl + F5.
Press F5. Sometimes some content will not be updated, and CTRL + F5 will update all content.
The specific differences are:
F5 usually only refreshes the local cache;
CTRL + F5: delete the files in the intenet Temporary Folder and download them from the server again, that is, refresh the page completely.