mysqli的预处理我就放出代码,大家对照手册研究一下作用

<?php
header('content-type:text/html;charset=utf-8');
$mysqli=new mysqli("localhost","root","dgj99349","xiaowei");
$mysqli->stmt_init();
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
//$sql=" insert into duguijin (price,geshu) values (?,?);";
$sql="select id,price,geshu from duguijin where id>?";
$stmt=$mysqli->prepare($sql);
$stmt->bind_param('i',$id);
$stmt->bind_result($id,$price,$geshu); 
$id=4;
$stmt->data_seek(2);
$stmt->execute();
$stmt->store_result(); //把所有结果接都取出来
$result=$stmt->result_metadata(); //取出自短信息
while($field=$result->fetch_field()){
	echo $field->name."--";
}
while($stmt->fetch()){
	echo "$id--$price--$geshu<br>";
}
echo "记录总数:".$stmt->num_rows;
$stmt->free_result();
$stmt->close();

//$mysqli->bind_param("ii",$price,$geshu);
/* $stmt=$mysqli->prepare($sql);
$stmt->bind_param("ii",$price,$geshu);
$price=11;
$geshu=22;
$stmt->execute();
$price=22;
$geshu=33;
$stmt->execute();
$price=33;
$geshu=44;
$stmt->execute();
echo $mysqli->insert_id."<br>";
echo $mysqli->affected_rows; */
mysql视图 一、什么是视图 视图是存放数据的一个接口,也可以说是虚拟表,这些数据可以是从一个或几个基表(视图)的数据,也可是用户自己定义的数据,其实视图里面不存放数据,数据据还是存在基表里面,基表数据发生变化,视图里的数据也随之变量,视图里数据变化,基表也会变化。 二、视图的作用 1. 视图可以让查询变得很清楚(复杂的SQL语句变得很简单) 2. 保护数据库的重要数据, 给不同的人看不同的数据 三、创建视图 create [or replace] [algorithm={merge|temptable|undefined}] view view_name [(column_list)] as select_statement [with [cascaded|local] check option] alter [or replace] [algorithm={merge|temptable|undefined}] view view_name [(column_list)] as select_statement [with [cascaded|local] check option] 视图有三种类型 Merge: 会将引用视图的语句的文本与视图定义结合起来,使用得视图定义的某一部分取代语句的对应部分 Temptable 临时表 undefined : Megre algorithm=merge with local check option [local]只要满足本视图的条件就可以更新 with cascaded check option [cascaded]则是必须满足所有针对视图的条件,才可以更新 定制视图: CREATE OR REPLACE VIEW stu3 AS SELECT name,age,sex FROM student WHERE a>40; 四、视图的操作 和mysql的操作一般没有什么区别 就是view 五、更改视图 alter [or replace] [algorithm={merge|temptable|undefined}] view view_name [(column_list)] as select_statement [with [cascaded|local] check option] 六、删除视图 drop view view_name,......;同时删除一个或多个 七、查看视图 SHOW tables; SHOW table status like 'stu2' \G; desc view_name; show create view stu2 \G;\\创建stu2时的语法 select * from information_schema.views \G;\\查看全部视图 欢迎转载,转载请注明来自微度网络-网络技术中心http://yun.widuu.com

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部