PDO::getAttribute
PHP 教程
· 2019-01-28 16:42:14
PDO::getAttribute — 取回一个数据库连接的属性(PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
说明
语法
mixed PDO::getAttribute ( int $attribute )
此函数(方法)返回一个数据库连接的属性值。 取回 PDOStatement 属性,请参阅 PDOStatement::getAttribute()。
注意有些数据库/驱动可能不支持所有的数据库连接属性。
参数说明:
attribute:
PDO::ATTR_* 常量中的一个。下列为应用到数据库连接中的常量:
- PDO::ATTR_AUTOCOMMIT
- PDO::ATTR_CASE
- PDO::ATTR_CLIENT_VERSION
- PDO::ATTR_CONNECTION_STATUS
- PDO::ATTR_DRIVER_NAME
- PDO::ATTR_ERRMODE
- PDO::ATTR_ORACLE_NULLS
- PDO::ATTR_PERSISTENT
- PDO::ATTR_PREFETCH
- PDO::ATTR_SERVER_INFO
- PDO::ATTR_SERVER_VERSION
- PDO::ATTR_TIMEOUT
返回值
成功调用则返回请求的 PDO 属性值。不成功则返回 null。
实例
取回数据库连接属性
<?php $conn = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); $attributes = array( "AUTOCOMMIT", "ERRMODE", "CASE", "CLIENT_VERSION", "CONNECTION_STATUS", "ORACLE_NULLS", "PERSISTENT", "PREFETCH", "SERVER_INFO", "SERVER_VERSION", "TIMEOUT" ); foreach ($attributes as $val) { echo "PDO::ATTR_$val: "; echo $conn->getAttribute(constant("PDO::ATTR_$val")) . "\n"; } ?>
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
Design and Analysis of Distributed Algorithms (Wiley Series on P
Nicola Santoro / Wiley-Interscience / 2006-10-27 / USD 140.95
This text is based on a simple and fully reactive computational model that allows for intuitive comprehension and logical designs. The principles and techniques presented can be applied to any distrib......一起来看看 《Design and Analysis of Distributed Algorithms (Wiley Series on P》 这本书的介绍吧!