This is not a document function, but you can do it from the database configuration file ( application/config/database.php ) by adding the options parameter, for example:
$db['default']['options'] = array(PDO::ATTR_TIMEOUT => 5);
Other settings that use the same internal mechanism (for example, PDO::MYSQL_ATTR_INIT_COMMAND set with $db['default']['stricton'] and PDO::MYSQL_ATTR_COMPRESS set with $db['default']['compress'] ), do not affect this.
If you want to dig deeper or check which parameters are set, you can write $this->options in db_connect in system/database/drivers/pdo/pdo_driver.php in system/database/drivers/pdo/pdo_driver.php , and also check database/drivers/pdo/subdrivers/pdo_mysql_driver.php .
source share