PHP mysqli real_query()関数
例-オブジェクト指向スタイル
単一のSQLクエリを実行します。store_result()で結果を保存します。
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
// Check connection
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
$mysqli -> real_query("SELECT * FROM Persons");
if ($mysqli -> field_count) {
$result = $mysqli -> store_result();
$row = $result -> fetch_row();
// Free result set
$result -> free_result();
}
$mysqli -> close();
?>
定義と使用法
real_query()/ mysqli_real_query()関数は、単一のSQLクエリを実行します。結果は、store_result()またはuse_result()関数を使用して取得または保存できます。
構文
オブジェクト指向スタイル:
$mysqli -> real_query(query)
手続き型:
mysqli_real_query(connection, query)
パラメータ値
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
query | Required. The query to be executed |
技術的な詳細
戻り値: | 成功するとTRUE。失敗するとFALSE |
---|---|
PHPバージョン: | 5歳以上 |
❮PHPMySQLiリファレンス