From bd44178bd5e2fee987cdb50eeba30b10a6dbd41d Mon Sep 17 00:00:00 2001 From: hawk__ Date: Mon, 1 Aug 2011 20:48:51 +0000 Subject: [PATCH] Moved Insert table name catching for insert ID retrieving to work properly git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@418055 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- pg4wp/driver_pgsql.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 18e8fc2..3959724 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -194,16 +194,6 @@ $logto = 'INSERT'; $sql = str_replace('(0,',"('0',", $sql); $sql = str_replace('(1,',"('1',", $sql); - $pattern = '/INSERT INTO (\w+)\s+\([ a-zA-Z_"]+/'; - preg_match($pattern, $sql, $matches); - $GLOBALS['pg4wp_ins_table'] = $matches[1]; - $match_list = split(' ', $matches[0]); - if( $GLOBALS['pg4wp_ins_table']) - { - $GLOBALS['pg4wp_ins_field'] = trim($match_list[3],' () '); - if(! $GLOBALS['pg4wp_ins_field']) - $GLOBALS['pg4wp_ins_field'] = trim($match_list[4],' () '); - } // ZdMultiLang support hack if( $GLOBALS['pg4wp_ins_table'] == $table_prefix.'zd_ml_trans') @@ -330,6 +320,21 @@ $sql = str_replace( array_keys($zdml_conv), array_values($zdml_conv), $sql); } + // For insert ID catching + if( $logto == 'INSERT') + { + $pattern = '/INSERT INTO (\w+)\s+\([ a-zA-Z_"]+/'; + preg_match($pattern, $sql, $matches); + $GLOBALS['pg4wp_ins_table'] = $matches[1]; + $match_list = split(' ', $matches[0]); + if( $GLOBALS['pg4wp_ins_table']) + { + $GLOBALS['pg4wp_ins_field'] = trim($match_list[3],' () '); + if(! $GLOBALS['pg4wp_ins_field']) + $GLOBALS['pg4wp_ins_field'] = trim($match_list[4],' () '); + } + } + // Put back the end of the query if it was separated $sql .= $end;