aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba
diff options
context:
space:
mode:
Diffstat (limited to 'include/dba')
-rw-r--r--include/dba/dba_pdo.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index b8b673727..7a1dfb48a 100644
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -146,10 +146,19 @@ class dba_pdo extends dba_driver {
array_values($data)
);
- $res = $this->q("INSERT INTO {$table} ("
+ $query = "INSERT INTO {$table} ("
. implode(', ', $keys) . ') VALUES ('
- . implode(', ', $values) . ')'
- );
+ . implode(', ', $values) . ')';
+
+ // MySQL is the only supported DB that don't support the returning
+ // clause. Since the driver type is 'mysql' also for MariaDB, we need
+ // to check the actual server version to be sure we only exclude actual
+ // MySQL systems.
+ if ($this->driver_dbtype !== 'mysql' || stripos($this->server_version, 'mariadb') !== false) {
+ $query .= ' RETURNING *';
+ }
+
+ $res = $this->q($query);
if (is_a($res, PDOStatement::class)) {
//