Skip to content

Commit 369588b

Browse files
committed
Use PDO subdriver constants and functions
1 parent 131edbf commit 369588b

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"source": "https://github.com/bcit-ci/CodeIgniter"
1212
},
1313
"require": {
14-
"php": ">=7.4"
14+
"php": ">=8.4"
1515
},
1616
"scripts": {
1717
"test:coverage": [

system/database/drivers/pdo/pdo_driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function db_connect($persistent = FALSE)
142142

143143
try
144144
{
145-
return new PDO($this->dsn, $this->username, $this->password, $this->options);
145+
return PDO::connect($this->dsn, $this->username, $this->password, $this->options);
146146
}
147147
catch (PDOException $e)
148148
{

system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,34 +143,34 @@ public function db_connect($persistent = FALSE)
143143

144144
if ( ! empty($sql))
145145
{
146-
if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND]))
146+
if (empty($this->options[Pdo\Mysql::ATTR_INIT_COMMAND]))
147147
{
148-
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode = '.$sql;
148+
$this->options[Pdo\Mysql::ATTR_INIT_COMMAND] = 'SET SESSION sql_mode = '.$sql;
149149
}
150150
else
151151
{
152-
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = '.$sql;
152+
$this->options[Pdo\Mysql::ATTR_INIT_COMMAND] .= ', @@session.sql_mode = '.$sql;
153153
}
154154
}
155155
}
156156

157157
if ($this->compress === TRUE)
158158
{
159-
$this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
159+
$this->options[Pdo\Mysql::ATTR_COMPRESS] = TRUE;
160160
}
161161

162162
if (is_array($this->encrypt))
163163
{
164164
$ssl = array();
165-
empty($this->encrypt['ssl_key']) OR $ssl[PDO::MYSQL_ATTR_SSL_KEY] = $this->encrypt['ssl_key'];
166-
empty($this->encrypt['ssl_cert']) OR $ssl[PDO::MYSQL_ATTR_SSL_CERT] = $this->encrypt['ssl_cert'];
167-
empty($this->encrypt['ssl_ca']) OR $ssl[PDO::MYSQL_ATTR_SSL_CA] = $this->encrypt['ssl_ca'];
168-
empty($this->encrypt['ssl_capath']) OR $ssl[PDO::MYSQL_ATTR_SSL_CAPATH] = $this->encrypt['ssl_capath'];
169-
empty($this->encrypt['ssl_cipher']) OR $ssl[PDO::MYSQL_ATTR_SSL_CIPHER] = $this->encrypt['ssl_cipher'];
165+
empty($this->encrypt['ssl_key']) OR $ssl[Pdo\Mysql::ATTR_SSL_KEY] = $this->encrypt['ssl_key'];
166+
empty($this->encrypt['ssl_cert']) OR $ssl[Pdo\Mysql::ATTR_SSL_CERT] = $this->encrypt['ssl_cert'];
167+
empty($this->encrypt['ssl_ca']) OR $ssl[Pdo\Mysql::ATTR_SSL_CA] = $this->encrypt['ssl_ca'];
168+
empty($this->encrypt['ssl_capath']) OR $ssl[Pdo\Mysql::ATTR_SSL_CAPATH] = $this->encrypt['ssl_capath'];
169+
empty($this->encrypt['ssl_cipher']) OR $ssl[Pdo\Mysql::ATTR_SSL_CIPHER] = $this->encrypt['ssl_cipher'];
170170

171-
if (defined('PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT') && isset($this->encrypt['ssl_verify']))
171+
if (defined('Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT') && isset($this->encrypt['ssl_verify']))
172172
{
173-
$ssl[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = $this->encrypt['ssl_verify'];
173+
$ssl[Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT] = $this->encrypt['ssl_verify'];
174174
}
175175

176176
// DO NOT use array_merge() here!

0 commit comments

Comments
 (0)