1. 連接數(shù)據(jù)庫(kù)
ysqlinect()函數(shù),該函數(shù)的參數(shù)包括數(shù)據(jù)庫(kù)地址、用戶名、密碼和數(shù)據(jù)庫(kù)名。示例代碼如下:
```ame = "localhost";ame = "root";
$password = "123456";ameyDB";
// 創(chuàng)建連接nysqlinectameameame);
// 檢測(cè)連接n) {nectionysqlinect_error());
}nected successfully";
2. 執(zhí)行SQL語句
ysqli_query()函數(shù)執(zhí)行SQL語句。該函數(shù)的第一個(gè)參數(shù)是連接對(duì)象,第二個(gè)參數(shù)是SQL語句。示例代碼如下:
```ameame FROM MyGuests";ysqlin, $sql);
ysqlium_rows($result) > 0) {
// 輸出數(shù)據(jù)ysqli_fetch_assoc($result)) {eameame"]. "<br>";
}
} else {
echo "0 results";
3. 關(guān)閉連接
ysqli_close()函數(shù)關(guān)閉連接。示例代碼如下:
```ysqlin);