SAE MYSQL 連線例項(建立一個表)
阿新 • • 發佈:2019-01-27
在SAE中訪問MySQL 示例程式碼: $con = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS); 使用者名稱 : SAE_MYSQL_USER 我的測試程式碼:(訪問資料庫,並建立一個名為Persons的資料表) $con = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS); |
<?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 "建表成功"; $mysql->closeDb(); ?>