php mysql execute_PHP mysqli_stmt_execute MySQLi 函数

定义和用法

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);

相关函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值