课程笔记
课程/PHP/后端开发
PDO—数据库抽象层
介绍
章节
问答
笔记
黄枪枪
2017-02-11
必须是最后使用pdo对象执行的SQL语句为插入语句时,调用pdo对象的lastInsertId()方法才能得到新插入记录的ID号,否则返回值为0.
0赞 · 0采集
qq_寒月shang雪shan_0
2016-10-28
删除 delete from 表名 where 删除列名=删除列值
0赞 · 0采集
qq_寒月shang雪shan_0
2016-10-28
更新一条记录 update 表名set 列名=更改值 where 列名=被更改值
0赞 · 0采集
流浪佳人纳入怀
2016-10-27
exec()执行更新和删除操作
截图
0赞 · 0采集
203
2016-06-21
exec()的删除更新操作
截图
0赞 · 0采集
netxfire
2016-05-31
exec语句对select查询语句不执行
0赞 · 0采集
墙头草
2016-02-28
<?php try{ $dsn = 'mysql:host=localhost;dbname=querytest'; $user = 'root'; $pass = '123456'; $dbh = new PDO($dsn, $user, $pass); /*演示更新和删除数据*/ //$sql = 'UPDATE `user` SET `username`="mook" WHERE `id`="1"'; $sql = 'DELETE FROM user WHERE id=1'; /*注意:exec方法对select查询没有作用!*/ $count = $dbh->exec($sql); echo '受影响的行数:'.$count.'<br />';; }catch(PDOException $e) { echo $e->getMessage(); }
0赞 · 0采集
phpcreate
2016-02-23
$pdo->lastInsertId()//可以自己用mysql测试一下,可以知道的是插入记录有影响,更新记录没有影响
0赞 · 1采集
fengyang
2015-08-10
<?php header('content-type:text/html;charset=utf-8'); try{ $pdo=new PDO('mysql:host=localhost;dbname=imooc','root','root'); //$sql='update user set username="king" where id=1'; //$sql='delete from user12 where id=1'; $sql='select * from user'; $res=$pdo->exec($sql); //echo $res.'条记录被影响'; var_dump($res); // echo '<hr/>'; // echo $pdo->lastInsertId(); }catch(PDOException $e){ echo $e->getMessage(); }
0赞 · 1采集
Hijay
2014-11-27
$pdo->exec($sql);对执行查询操作是无效的。
0赞 · 0采集
JaysonLee
2014-10-29
$pdo->exec($sql);对select的语句没有作用。 <<<EOF(自定义) EOF;一定要顶格写
0赞 · 0采集
天使之城
2014-10-28
delete
截图
0赞 · 0采集
天使之城
2014-10-28
update
截图
0赞 · 0采集
天使之城
2014-10-28
lastInsertId()
截图
1赞 · 1采集
数据加载中...