File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,23 @@ public function getDefaultConnectionParams($type) {
8888 throw new \InvalidArgumentException ("Unsupported type: $ type " );
8989 }
9090 $ result = $ this ->defaultConnectionParams [$ normalizedType ];
91- // \PDO::MYSQL_ATTR_FOUND_ROWS may not be defined, e.g. when the MySQL
92- // driver is missing. In this case, we won't be able to connect anyway.
93- if ($ normalizedType === 'mysql ' && defined ('\PDO::MYSQL_ATTR_FOUND_ROWS ' )) {
94- $ result ['driverOptions ' ] = [
95- \PDO ::MYSQL_ATTR_FOUND_ROWS => true ,
96- ];
91+ /**
92+ * {@see \PDO::MYSQL_ATTR_FOUND_ROWS} may not be defined, e.g. when the MySQL
93+ * driver is missing. In this case, we won't be able to connect anyway.
94+ * In PHP 8.5 it's deprecated and {@see \Pdo\Mysql::ATTR_FOUND_ROWS} should be used,
95+ * but that is only available since PHP 8.4
96+ */
97+ if ($ normalizedType === 'mysql ' ) {
98+ if (PHP_VERSION_ID >= 80500 && class_exists (\Pdo \Mysql::class)) {
99+ /** @psalm-suppress UndefinedClass */
100+ $ result ['driverOptions ' ] = [
101+ \Pdo \Mysql::ATTR_FOUND_ROWS => true ,
102+ ];
103+ } elseif (PHP_VERSION_ID < 80500 && defined ('\PDO::MYSQL_ATTR_FOUND_ROWS ' )) {
104+ $ result ['driverOptions ' ] = [
105+ \PDO ::MYSQL_ATTR_FOUND_ROWS => true ,
106+ ];
107+ }
97108 }
98109 return $ result ;
99110 }
Original file line number Diff line number Diff line change @@ -44,7 +44,11 @@ public function postConnect(ConnectionEventArgs $args) {
4444 /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */
4545 $ connection = $ args ->getConnection ()->getWrappedConnection ();
4646 $ pdo = $ connection ->getWrappedConnection ();
47- $ pdo ->sqliteCreateFunction ('md5 ' , 'md5 ' , 1 );
47+ if (PHP_VERSION_ID >= 80500 && method_exists ($ pdo , 'createFunction ' )) {
48+ $ pdo ->createFunction ('md5 ' , 'md5 ' , 1 );
49+ } else {
50+ $ pdo ->sqliteCreateFunction ('md5 ' , 'md5 ' , 1 );
51+ }
4852 }
4953
5054 public function getSubscribedEvents () {
You can’t perform that action at this time.
0 commit comments