如何在Codeigniter中将属性设置为PDO连接 [英] How to set Attribute to PDO connection in Codeigniter
本文介绍了如何在Codeigniter中将属性设置为PDO连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Codeigniter的PDO数据库句柄上设置属性(PDO :: ATTR_ERRMODE)?
How to set attributes (PDO::ATTR_ERRMODE) on the PDO database handle in Codeigniter?
推荐答案
我认为更好选项是使用MY_Model(然后对其进行扩展,然后可以在整个应用程序中使用它),并在构造中定义以下内容:
I think a better option is to use a MY_Model (which you then extend and this is available then across the application) and define something like this in the construct:
$ this-> db-> conn_id-> setAttribute(PDO :: ATTR_ERRMODE,PDO :: ERRMODE_EXCEPTION);
请注意conn_id允许您访问主PDO对象。
Note conn_id allows you to access the main PDO object.
这篇关于如何在Codeigniter中将属性设置为PDO连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文