php的PDO手记1
首先可以通过phpinfo()查看下你的PDO扩展是否启用:http://xcf007.blog.运维网.com/attachment/200811/200811101226285423687.jpg
如果启用了,继续:
http://xcf007.blog.运维网.com/images/editer/InBlock.gif
连接测试。
如果连接失败会如下:
比如密码错误:
连接失败: SQLSTATE Access denied for user 'root'@'localhost' (using password: YES)
对了PDO构造函数,如果连接失败会抛出一个异常
Errors/Exceptions
PDO->__construct() throws a PDOException if the attempt to connect to the requested database fails.
所以应该捕获这个异常作出处理。
页:
[1]