Blogger Information
Blog 28
fans 1
comment 0
visits 17283
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019.6.5作业
关超的博客
Original
726 people have browsed it
  1. 写出PDO操作数据库的基本步骤

    链接数据库,创建pdo对象

    $pdo = new PDO($DSN,$username,$password)

    执行sql语句

    创建sql语句对象  $stmt = $pdo->prepare($sql)

    执行sql查询 $stmt ->execute()

    对执行结果进行解析或进一步处理

    关闭数据库链接   $pdo = null;



2 创始一个学生数据库与学生信息表, 练习常用的增删改查语句
select, update, insert, delete


CREATE TABLE `student` (

                          `stu_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',

                          `name` varchar(50) NOT NULL COMMENT '姓名',

                          `age` int(10) NOT NULL COMMENT '年龄',

                          `sex` int(1) NOT NULL COMMENT '性别',

                          PRIMARY KEY (`stu_id`)



select * from student where stu_id = 10;

INSERT INTO `student` (`stu_id`, `name`, `age`, `sex`) VALUES

(1, '超', 30,1);

update student set age = 31 where stu_id= 1;

delete from student where stu_id = 1;

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post