Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Attribute to PDO connection in Codeigniter

How to set attributes (PDO::ATTR_ERRMODE) on the PDO database handle in Codeigniter?

like image 227
ProgZi Avatar asked May 21 '26 21:05

ProgZi


1 Answers

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);

Note conn_id allows you to access the main PDO object.

like image 170
Antony Avatar answered May 25 '26 15:05

Antony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!