mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-08-01 02:34:27 +02:00
correct the REGEX for returning statements to account for backticks around table name
This commit is contained in:
@@ -533,16 +533,16 @@ function wpsqli_query(&$connection, $query, $result_mode = 0)
|
|||||||
$GLOBALS['pg4wp_conn'] = $connection;
|
$GLOBALS['pg4wp_conn'] = $connection;
|
||||||
$GLOBALS['pg4wp_result'] = $result;
|
$GLOBALS['pg4wp_result'] = $result;
|
||||||
|
|
||||||
if (false !== str_post("INSERT INTO")) {
|
if (false !== strpos($sql, "INSERT INTO")) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match("/^INSERT INTO ([a-z0-9_]+)/i", $query, $matches);
|
preg_match("/^INSERT INTO\s+`?([a-z0-9_]+)`?/i", $query, $matches);
|
||||||
$tableName = $matches[1];
|
$tableName = $matches[1];
|
||||||
|
|
||||||
if (false !== str_pos($sql, "RETURNING")) {
|
if (false !== strpos($sql, "RETURNING")) {
|
||||||
$primaryKey = $this->get_primary_key_for_table($connection, $tableName);
|
$primaryKey = get_primary_key_for_table($connection, $tableName);
|
||||||
$row = pg_fetch_assoc($result);
|
$row = pg_fetch_assoc($result);
|
||||||
|
|
||||||
$GLOBALS['pg4wp_ins_id'] = $row[$primaryKey];
|
$GLOBALS['pg4wp_ins_id'] = $row[$primaryKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user