Php/func mysqli real query
来自菜鸟教程
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)
参数值
| 参数 | 描述 |
|---|---|
| connection | 需要。指定要使用的MySQL连接 |
| query | 需要。要执行的查询 |
技术细节
| 返回值: | 成功则为真。失败时为假 |
| PHP版本: | 5+ |