Blogger Information
Blog 41
fans 0
comment 0
visits 29612
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0605作业2019年6月9日12点29分
Viggo的博客
Original
645 people have browsed it

作业1、写出PDO的操作步骤

1.配置数据库信息
    $db =[
        'type'='mysql',
        'host'='localhost',
        'dbname'='php',
        'username'='root',
        'password'='root'
    ]
2.配置数据源
    //$data = "mysql:host=localhost;dbname=php";//示范
    $data ="{$db['type']}:host={$db['host']};dbname={$db['dbname']}";
3.创建PDO对象连接
    $pdo = new PDO($data,$db['username'],$db['password']);


3.开始操作数据库
    1.加载前面的1、2两项文件.
    2.配置SQL语句
    3.预处理paepare();
    4.绑定变量(这一步是为了方便设置SQL的参数)
    5.执行SQL语句
    6.遍历获取到的数据
    7.关闭PDO连接




作业2、创建学生表,练习常用的增删改查语句

插入语句
INSERT INTO()VALUES();
INSERT INTO SET `插入的字段` =`插入的值`,`插入的字段` =`插入的值`
删除语句
DELETE FROM `表名` WHERE `条件`
更新语句
UPDATE `表名` SET `更新的字段`=`更新的值`,`更新的字段`=`更新的值` WHERE `条件`
查询语句
SELECT * FROM `表名` WHERE `条件`


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