Skip to content

Commit 47427fe

Browse files
committed
Better MYSQLI_REPORT_OFF implementations for php8.1 compat
Thanks @mentalstring
1 parent 93f249d commit 47427fe

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/database/sfMySQLiDatabase.class.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
class sfMySQLiDatabase extends sfMySQLDatabase
1919
{
2020

21+
/**
22+
* @return void
23+
* @throws sfDatabaseException
24+
*/
25+
public function connect()
26+
{
27+
// PHP 8.1 Activate Exception per default, revert behavior to "return false"
28+
mysqli_report(MYSQLI_REPORT_OFF);
29+
30+
parent::connect();
31+
}
32+
2133
/**
2234
* Returns the appropriate connect method.
2335
*
@@ -29,9 +41,6 @@ class sfMySQLiDatabase extends sfMySQLDatabase
2941
*/
3042
protected function getConnectMethod($persistent)
3143
{
32-
// PHP 8.1 Activate Exception per default, revert behavior to "return false"
33-
mysqli_report(MYSQLI_REPORT_OFF);
34-
3544
return 'mysqli_connect';
3645
}
3746

0 commit comments

Comments
 (0)