}
return $defval;
}
+
+if (!function_exists('str_contains')) {
+ /**
+ * PHP8 str_contains polyfill
+ *
+ * based on original work from the PHP Laravel framework
+ * see https://www.php.net/manual/fr/function.str-contains.php#125977
+ *
+ * @param string $haystack The string to search in.
+ * @param string $needle The substring to search for in the haystack
+ *
+ * @return bool
+ */
+ function str_contains($haystack, $needle)
+ {
+ return $needle !== '' && mb_strpos($haystack, $needle) !== false;
+ }
+}
if ($fatal_error) {
$zdb->connection->rollBack();
} else {
- $zdb->connection->commit();
+ try {
+ $zdb->connection->commit();
+ } catch (\PDOException $e) {
+ //to avoid php8/mysql autocommit issue
+ if ($zdb->isPostgres() || (!$zdb->isPostgres() && !str_contains($e->getMessage(), 'no active transaction'))) {
+ throw $e;
+ }
+ }
}
$this->_report = array_merge($this->_report, $queries_results);