mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-08-01 18:54:25 +02:00
correct regex for insert matching
This commit is contained in:
@@ -71,18 +71,26 @@ function pg4wp_rewrite($sql)
|
|||||||
// Put back the end of the query if it was separated
|
// Put back the end of the query if it was separated
|
||||||
$sql .= $end;
|
$sql .= $end;
|
||||||
|
|
||||||
// For insert ID catching
|
// For insert ID caching
|
||||||
if($logto == 'INSERT') {
|
if($logto == 'INSERT') {
|
||||||
$pattern = '/INSERT INTO (\w+)\s+\([ a-zA-Z_"]+/';
|
$pattern = '/INSERT INTO "?([\w_]+)"? \(([^)]+)\)/i';
|
||||||
preg_match($pattern, $sql, $matches);
|
preg_match($pattern, $sql, $matches);
|
||||||
$GLOBALS['pg4wp_ins_table'] = $matches[1];
|
|
||||||
$match_list = explode(' ', $matches[0]);
|
if (isset($matches[1])) {
|
||||||
if($GLOBALS['pg4wp_ins_table']) {
|
$GLOBALS['pg4wp_ins_table'] = $matches[1];
|
||||||
$GLOBALS['pg4wp_ins_field'] = trim($match_list[3], ' () ');
|
}
|
||||||
if(!$GLOBALS['pg4wp_ins_field']) {
|
|
||||||
$GLOBALS['pg4wp_ins_field'] = trim($match_list[4], ' () ');
|
if (isset($matches[2])) {
|
||||||
|
$columns_str = $matches[2];
|
||||||
|
$columns = explode(',', $columns_str);
|
||||||
|
$columns = array_map(function ($column) {
|
||||||
|
return trim(trim($column), '"');
|
||||||
|
}, $columns);
|
||||||
|
if (isset($columns[0])) {
|
||||||
|
$GLOBALS['pg4wp_ins_field'] = $columns[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['pg4wp_last_insert'] = $sql;
|
$GLOBALS['pg4wp_last_insert'] = $sql;
|
||||||
} elseif(isset($GLOBALS['pg4wp_queued_query'])) {
|
} elseif(isset($GLOBALS['pg4wp_queued_query'])) {
|
||||||
pg_query($GLOBALS['pg4wp_queued_query']);
|
pg_query($GLOBALS['pg4wp_queued_query']);
|
||||||
|
@@ -42,6 +42,8 @@ PG4WP 2.0 will have a mechanism to add plugin support.
|
|||||||
| Theme | Version | Working |
|
| Theme | Version | Working |
|
||||||
| ----------- | ----------- | --------- |
|
| ----------- | ----------- | --------- |
|
||||||
| Twenty Twenty-Three | 1.2 | Confirmed |
|
| Twenty Twenty-Three | 1.2 | Confirmed |
|
||||||
|
| Twenty Twenty-Two | 1.5 | Confirmed |
|
||||||
|
| Twenty Twenty-One | 1.9 | Confirmed |
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user