php pdo and pdostatement
I'm a php and mysql beginner, I'm currently self study PDO and confused some concepts:
1.What is the relationship between PDO class and PDOStatement class?
2.Someone said $users is the cursor, once consumed, it won't rewind to the beginning of the resultset.
but why you can use it in a 3.For the pdostatement class, the doc said:
why this class implements Traversable interface? is it empty interface? Thank you for help!
|
|||||||||||||||||
|
According to the documentation, the Basically, with PDO there is two ways to execute a query, one by using PDO::prepare() & PDOStatement::execute() and the other one by using PDO::query(). The later does prepare/execute in one call.
It seems more complicated on first sight but it provides more flexibility. |
|||
All that mess is called "syntax sugar" and intended to sweeten a developer's life, though in real it makes taste too sugary to the point of disgust. So, there are two kinds of object's characteristics - natural and unnatural ones. In your place I'd just forget of them, using objects straight way.
That's 2 different classes. They serve different purposes. Like in old mysql you had connection resource and result resource. You have only one connection/PDO instance, but there can be any number actual query results/stmt classes.
That's the very syntax sugar I talked above. They just added such a possibility to the statement object. |
php pdo and pdostatement的更多相关文章
- PDO、PDOStatement、PDOException
最近在学PDO 比较详细的资料 出处:http://blog.csdn.net/hsst027/article/details/23682003 PDO中包含三个预定义的类,它们分别是PDO.PDO ...
- PDO和PDOStatement类常用方法
PDO — PDO 类 PDO::beginTransaction — 启动一个事务 PDO::commit — 提交一个事务 PDO::__construct — 创建一个表示数据库连接的 PDO ...
- PDO和消息队列的一点个人理解
什么是消息队列,百度百科说,···消息队列····是在消息的传输过程中保存消息的容器. 看着网上林林总总的文章,都说是为了应对高并发,处理数据量超级大的一种数据容器,也可以说是利用各种方式,先把数据存 ...
- PHP PDO函数库详解
PDO是一个“数据库访问抽象层”,作用是统一各种数据库的访问接口,与mysql和mysqli的函数库相比,PDO让跨数据库的使用更具有亲和力:与ADODB和MDB2相比,PDO更高效.目前而言,实现“ ...
- pdo简单操作
PDO(PHP Data Object) 是PHP 5新出来的东西,在PHP 6都要出来的时候,PHP 6只默认使用PDO来处理数据库,将把所有的数据库扩展移到了PECL,那么默认就是没有了我们喜爱的 ...
- PHP中PDO的配置与说明
住[PDO是啥] PDO是PHP5新加入的一个重大功能,因为在PHP5以前的php4/php3都是一堆的数据库扩展来跟各个数据库的连接和处理,什么php_mysql.dll.php_pgsql.dll ...
- PHP5中PDO的简单使用
PHP5中PDO的简单使用 标签: php数据库mysql扩展extensionexception 2012-05-06 10:27 27753人阅读 评论(0) 收藏 举报 分类: PHP(6) ...
- PHP PDO函数库具体解释
文章来源:PHP开发学习门户 地址:http://www.phpthinking.com/archives/565 PDO是一个"数据库訪问抽象层",作用是统一各种数据库的訪问接口 ...
- 使用PDO持久化连接
无论是何种编程语言,几乎都要经常与各种数据库打交道.不过,众所周知的是,在程序与数据库之间建立连接是一件比较耗费资源的事情,因此编程技术领域的许多专家.前辈们就设想并提出了各种解决方案,以减少不必要的 ...
随机推荐
- java中的反射机制_____
一,先看一下反射的概念: 主要是指程序可以访问,检测和修改它本身状态或行为的一种能力,并能根据自身行为的状态和结果,调整或修改应用所描述行为的状态和相关的语义. 反射是java中一种强大的工具,能够使 ...
- 关于Trie Tree简单实现
最近突然有兴致hiho一下了,实现了下trie tree,感觉而言,还是挺有意思的,个人觉得这货不光可以用来查单词吧,其实也可以用来替代Hash,反正查找,插入复杂度都挺低的,哈哈,啥都不懂,瞎扯.. ...
- 注册表对比工具(Regshot) V2.0.1 中文绿色版
软件名称: 注册表对比工具(Regshot)软件语言: 简体中文授权方式: 免费软件运行环境: Win7 / Vista / WinXP软件大小: 263KB图片预览: 软件简介:Regshot 是一 ...
- 《CSS网站布局实录》读书笔记
从Web标准.HTML标记.CSS语法基础介绍到实用技巧,事无巨细.实体书已不印刷,只能下载电子版 书的背景: 国内第一本web标准的CSS布局书,2006年9月第一版,作者李超. 环境背景: 当时主 ...
- 7、Objective-C中的各种遍历(迭代)方式
一.使用for循环 要遍历字典.数组或者是集合,for循环是最简单也用的比较多的方法,示例如下: //普通的for循环遍历 -(void)iteratorWithFor { //////////处理数 ...
- (repost)在ARM Linux内核中增加一个新的系统调用
实验平台内核版本为4.0-rc1,增加一仅仅打印Hello World的syscall,最后我们在用户空间swi验证 实验平台内核版本为4.0-rc1,增加的系统调用仅仅是简单打印一个Hello Wo ...
- Byte Array to Hexadecimal String
Lookup Text: 23,879.41 (20.8X faster) Sentence: 1.15 (23.9X faster) /// <summary> /// Hex stri ...
- win10 Incredibuild 兼容
电脑换了win10,所有的软件都需要重新安装. win10的体验还是很不错的.但是也有一堆的问题.原来的vs2010今天无法再使用分布式编译IncrediBuild. 现象是,虽然可以连上分布式编译的 ...
- 使用Interface创建的装饰者实现了必需的方法
很多开发团队也越来越认识到,自动化测试和持续部署可帮助开发团队提高迭代效率和质量.必须要有一份拿的出手的技术.社会不比在学校,上课随便听听,通过考试就行了,实在不行还有补考.在公司里,不是这样的. 正 ...
- javascript keycode
keycode 8 = BackSpace BackSpacekeycode 9 = Tab Tabkeycode 12 = Clearkeycode 13 = Enterkeyc ...