小白教程
所有教程
关于
Search
172.69.58.42
172.69.58.42
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func mysqli stmt init”的源代码
本页内容
上一节:
Func_mysqli_stat
下一节:
Func_mysqli_thread_id
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:mysqli_stmt_init()}}[[Category:PHP MySQLi 函数参考手册|59]] = PHP mysqli_stmt_init() 函数 = [[:Category:PHP MySQLi 函数参考手册]] 初始化声明并返回 mysqli_stmt_prepare() 使用的对象: <sample title="" desc="" lang="php" hererun="1"> <?php // 假定数据库用户名:root,密码:123456,数据库:XiaoBai.Wang $con=mysqli_connect("localhost","root","123456","XiaoBai.Wang"); if (mysqli_connect_errno($con)) { echo "连接 MySQL 失败: " . mysqli_connect_error(); } // 修改数据库连接字符集为 utf8 mysqli_set_charset($con,"utf8"); $country="CN"; // 创建预处理语句 $stmt=mysqli_stmt_init($con); if (mysqli_stmt_prepare($stmt,"SELECT name FROM websites WHERE country=?")) { // 绑定参数 mysqli_stmt_bind_param($stmt,"s",$country); // 执行查询 mysqli_stmt_execute($stmt); // 绑定结果变量 mysqli_stmt_bind_result($stmt,$name); // 获取值 mysqli_stmt_fetch($stmt); printf("%s 国家的网站为:%s",$country,$name); // 关闭预处理语句 mysqli_stmt_close($stmt); } mysqli_close($con); ?> </sample> == 定义和用法 == mysqli_stmt_init() 函数初始化声明并返回 mysqli_stmt_prepare() 使用的对象。 == 语法 == <pre> mysqli_stmt_init(connection); </pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | connection | 必需。规定要使用的 MySQL 连接。 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回一个对象。 |- | PHP 版本: | 5+ |} [[:Category:PHP MySQLi 函数参考手册]]
返回至“
Func mysqli stmt init
”。
上一节:
Func_mysqli_stat
下一节:
Func_mysqli_thread_id