PHP PDOStatement::setAttribute讲解
PDOStatement::setAttribute
PDOStatement::setAttribute — 设置一个语句属性(PHP 5 >= 5.1.0, PECL pdo >= 0.2.0)
说明
语法
bool PDOStatement::setAttribute ( int $attribute , mixed $value )
给语句设置一个属性。当前,没有通用的属性可以设置,只有驱动特定的属性:
_PDO::ATTR_CURSORNAME (Firebird 和 ODBC 特性): 为 UPDATE ... WHERE CURRENT OF 设置游标名称。
返回值
成功时返回 TRUE, 或者在失败时返回 FALSE。
代码示例
<?php $database = "AdventureWorks"; $server = "(local)"; $conn = new PDO( "sqlsrv:server=$server ; Database = $database", "", "", array('MultipleActiveResultSets'=>false ) ); $stmt = $conn->prepare('SELECT * FROM Person.ContactType'); echo $stmt->getAttribute( constant( "PDO::ATTR_CURSOR" ) ); echo "\n"; $stmt->setAttribute(PDO::SQLSRV_ATTR_QUERY_TIMEOUT, 2); echo $stmt->getAttribute( constant( "PDO::SQLSRV_ATTR_QUERY_TIMEOUT" ) ); ?>
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对我们的支持。如果你想了解更多相关内容请查看下面相关链接
相关推荐
-
PHP attributes()函数讲解
PHP attributes() 函数 实例 返回 XML 的 body 元素的属性和值: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body date="2013-01-01" type="private">Don'
-
PHP getNamespaces()函数讲解
PHP getNamespaces() 函数 实例 返回 XML 文档中使用的命名空间: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars xmlns:c="http://codingdict.com/ns" xmlns:a="http://codingdict.com/country"> <c:c
-
PHP registerXPathNamespace()函数讲解
PHP registerXPathNamespace() 函数 实例 为下一个 XPath 查询创建命名空间上下文: <?php $xml=<<<XML <book xmlns:chap="http://example.org/chapter-title"> <title>My Book</title> <chapter id="1"> <chap:title>Chapter 1&l
-
PHP addAttribute()函数讲解
PHP addAttribute() 函数 实例 给根元素和 body 元素添加一个属性: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
-
PHP _construct()函数讲解
PHP _construct() 函数 实例 函数创建一个新的 SimpleXMLElement 对象,然后输出 body 节点的内容: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</
-
PHP getName()函数讲解
PHP getName() 函数 实例 返回 XML 元素及其子元素的名称: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars> <car id="1">Volvo</car> <car id="2">BMW</car> <car id="3
-
PHP PDOStatement::setFetchMode讲解
PDOStatement::setFetchMode PDOStatement::setFetchMode - 为语句设置默认的获取模式.(PHP 5 >= 5.1.0, PECL pdo >= 0.2.0) 说明 语法 bool PDOStatement::setFetchMode ( int $mode ) bool PDOStatement::setFetchMode ( int $PDO::FETCH_COLUMN , int $colno ) bool PDOStatement::s
-
PHP asXML()函数讲解
PHP asXML()函数 实例 格式化 XML(版本 1.0)中的 SimpleXML 对象的数据: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </not
-
PHP children()函数讲解
PHP children() 函数 实例 查找 note 节点的子节点: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML; $xml
-
PHP getDocNamespaces()函数讲解
PHP getDocNamespaces() 函数 实例 返回 XML 文档的根节点中声明的命名空间: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars xmlns:c="http://codingdict.com/ns"> <c:car id="1">Volvo</c:car>
随机推荐
- PHP网页 Ewebeditor 编辑器嵌入方法
- IRC后门病毒及手动清除方法
- Oracle索引(B*tree与Bitmap)的学习总结
- JS基于正则表达式实现的密码强度验证功能示例
- Python中每次处理一个字符的5种方法
- JavaScript原型链示例分享
- asp.net中调用存储过程的方法
- php获取地址栏信息的代码
- php中stream(流)的用法
- Mysql5.7.18的安装与主从复制图文详解
- 关于Javascript作用域链的八点总结
- Python-嵌套列表list的全面解析
- jQuery实现级联下拉框实战(5)
- C++程序设计-五子棋
- Zend studio文件注释模板设置方法
- 使用TextRange获取输入框中光标的位
- 详解android与服务端交互的两种方式
- Zend Framework生成验证码并实现验证码验证功能(附demo源码下载)
- php可变长参数处理函数详解
- Intellij IDEA创建spring-boot项目的图文教程