温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP mysqli_stmt_execute MySQLi

发布时间:2020-07-29 07:02:29 来源:网络 阅读:173 作者:web全栈 栏目:web开发

定义和用法

mysqli_stmt_execute - 执行准备好的查询

版本支持

PHP4PHP5PHP7
不支持支持支持

语法

mysqli_stmt_execute ( mysqli_stmt $stmt )

执行以前使用 mysqli_prepare() 函数准备的查询。 执行后,任何存在的参数标记将自动替换为适当的数据。 如果该语句是UPDATE,DELETE或INSERT,则可以使用 mysqli_stmt_affected_rows() 函数确定受影响的行总数。 同样,如果查询产生结果集,则使用 mysqli_stmt_fetch() 函数。

注意: 使用mysqli_stmt_execute()时,必须在执行任何其他查询之前使用mysqli_stmt_fetch()函数来获取数据。

参数

参数必需的描述
stmt由 mysqli_stmt_init() 返回的 statement 标识。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。

示例

<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_query($link, "CREATE TABLE myCountry LIKE Country");
mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country");
$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
if ($stmt = mysqli_prepare($link, $query)) {
/* drop table */
mysqli_query($link, "DROP TABLE myCountry");
/* execute query */
mysqli_stmt_execute($stmt);
printf("Error: %s.\n", mysqli_stmt_execute($stmt));
/* close statement */
mysqli_stmt_close($stmt);
}
/* close connection */
mysqli_close($link);

相关函数

mysqli_prepare() - 准备执行一个SQL语句

mysqli_stmt_bind_param() - 将变量绑定到准备好的语句作为参数

mysqli_stmt_get_result() - 从准备好的语句获取结果集


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI