PHP学习 mysqli执行多条语句
2014-03-10 23:26
260 查看
<?php
$mysqli=new mysqli("localhost", "root", "123456", "xsphpdb");
//有结果集多个select语句
$sqls="select current_user();";
$sqls.="desc shops;";
$sqls.="select * from shops;";
$sqls.="select current_date()";
if($mysqli->multi_query($sqls)){
echo "执行成功!<br>";
do{
$result=$mysqli->store_result();
echo '<table align="center" border="1" width='.(100*$result->field_count).'>';
echo '<tr>';
while($field=$result->fetch_field()){
echo '<th>'.$field->name.'</th>';
}
echo '</tr>';
while($row=$result->fetch_assoc()){
echo '<tr>';
foreach($row as $col){
echo '<td>'.$col.'</td>';
}
echo '</tr>';
}
echo '</table>';
if($mysqli->more_results()){
echo '<p>--<p>--<p>';
}
}while($mysqli->next_result());
}else{
echo "ERROR:".$mysqli->errno."--".$mysqli->error;
}
$mysqli->close();
$mysqli=new mysqli("localhost", "root", "123456", "xsphpdb");
//有结果集多个select语句
$sqls="select current_user();";
$sqls.="desc shops;";
$sqls.="select * from shops;";
$sqls.="select current_date()";
if($mysqli->multi_query($sqls)){
echo "执行成功!<br>";
do{
$result=$mysqli->store_result();
echo '<table align="center" border="1" width='.(100*$result->field_count).'>';
echo '<tr>';
while($field=$result->fetch_field()){
echo '<th>'.$field->name.'</th>';
}
echo '</tr>';
while($row=$result->fetch_assoc()){
echo '<tr>';
foreach($row as $col){
echo '<td>'.$col.'</td>';
}
echo '</tr>';
}
echo '</table>';
if($mysqli->more_results()){
echo '<p>--<p>--<p>';
}
}while($mysqli->next_result());
}else{
echo "ERROR:".$mysqli->errno."--".$mysqli->error;
}
$mysqli->close();
相关文章推荐
- PHP使用mysqli同时执行多条sql查询语句
- PHP的 Mysqli扩展库的多语句执行
- mysqli->multi_query()执行多条语句
- mysqli->multi_query()执行多条语句
- PHP简单mysql管理工具,支持执行多条mysql语句!
- PHP简单mysql管理工具,支持执行多条mysql语句!
- PHP简单mysql管理工具,支持执行多条mysql语句!
- PHP mysqli 增强 批量执行sql 语句的实现代码
- 学习:C#一次性执行多条语句(查询的是不同的表 DataTable和DataSet)
- PHP实现mysqli批量执行多条语句的方法示例
- 使用mysqli一次执行多条SQL语句
- PHPmysqli的 预处理执行插入语句
- PHP mysqli 增强 批量执行sql 语句的实现代码
- PHPmysqli的 预处理执行查询语句
- PHP一次执行多条sql语句
- PHP mysqli 增强-批量执行sql 语句
- mysqli 批量执行多条语句
- PHP mysqli 增强 批量执行sql 语句的实现代码
- php学习笔记(十九)mysqli扩展库的多语句查询、事物处理以及字符集设置
- PHP mysqli 增强 批量执行sql 语句的实现代码