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持久化连接
无论是何种编程语言,几乎都要经常与各种数据库打交道.不过,众所周知的是,在程序与数据库之间建立连接是一件比较耗费资源的事情,因此编程技术领域的许多专家.前辈们就设想并提出了各种解决方案,以减少不必要的 ...
随机推荐
- c:set 存值
<c:forEach items="${appoint}" var="appoint"> <c:set var="begin&quo ...
- git在webstorm中的使用
打开webstorm新建项目,这里新建的项目名称我起为lianxi 打开设置选项里的插件栏 搜索gitignore,并安装,我这里已安装,所以显示X,没有安装的会显示一个绿色的下载箭头.安装完后需要重 ...
- pymongo数据报表脚本
最近打算将平时自己的一些小工具整理整理,由于一直使用python写脚本,而且数据库一直使用MongoDB,所以直接使用pymonogo驱动数据库做一些报表生成的小脚本,此次的脚本主要针对每个月中公司业 ...
- html绑定
目的 html绑定可以绑定DOM元素内的HTML内容. 示例: <div data-bind="html: details"></div> <scri ...
- 学会Nodejs 的require和exports
NodeJs中模块的导入和导出,是最基本的概念,但是看了之后,心里还是有一些疑惑的地方,比如: 1.有两个文件:part.js 和 main.js,main.js中要想使用part.js中定义的变量和 ...
- Thrift框架简介
功能:实现各个服务模块之间的跨语言.跨平台的通信,是RPC框架的一种,与dubbo类似. Thrift的应用原理: Thrift的部分功能相当于代码生成引擎,使用Thrift定义的语言编写*.Thri ...
- css 样式那些事
1. input placeholder 的颜色修改 ::-moz-placeholder { color: #f3d999; } ::-webkit-input-placeholder { ...
- Android: Failure [INSTALL_FAILED_DEXOPT] and Failure [INSTALL_FAILED_UID_CHANGED] 解决方案
1. 错误: Failure [INSTALL_FAILED_DEXOPT] Android安装App时 D:\WorkSpace\Administrator\workspace\svn\soot ...
- Socket.io 延伸
项目正好用到了即时通讯功能,于是研究到了webSocket技术,后来发现了可以在web.[Android].[iOS]上同时使用的解决方案,那就是SocketIO.其实现原理啥的不做介绍了,直接贴上I ...
- eclipse保存时自动格式化代码和优化导包

