Changeset 547119
- Timestamp:
- 05/21/2012 06:06:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postgresql-for-wordpress/trunk/pg4wp/driver_pgsql.php
r546732 r547119 23 23 $GLOBALS['pg4wp_ins_table'] = ''; 24 24 $GLOBALS['pg4wp_ins_field'] = ''; 25 $GLOBALS['pg4wp_last_insert'] = ''; 25 26 $GLOBALS['pg4wp_connstr'] = ''; 26 27 $GLOBALS['pg4wp_conn'] = false; … … 150 151 $ins_field = $GLOBALS['pg4wp_ins_field']; 151 152 $table = $GLOBALS['pg4wp_ins_table']; 153 $lastq = $GLOBALS['pg4wp_last_insert']; 152 154 153 155 $seq = $table . '_seq'; 154 156 155 157 // Table 'term_relationships' doesn't have a sequence 156 if( $table == $wpdb->term_relationships || 'post_author' == $ins_field)158 if( $table == $wpdb->term_relationships) 157 159 { 158 160 $sql = 'NO QUERY'; 159 161 $data = 0; 162 } 163 // When using WP_Import plugin, ID is defined in the query 164 elseif('post_author' == $ins_field && false !== strpos($lastq,'ID')) 165 { 166 $sql = 'ID was in query '; 167 $pattern = '/.+\'(\d+).+$/'; 168 preg_match($pattern, $lastq, $matches); 169 $data = $matches[1]; 170 // We should update the sequence on the next non-INSERT query 171 $GLOBALS['pg4wp_queued_query'] = "SELECT SETVAL('$seq',(SELECT MAX(\"ID\") FROM $table)+1);"; 160 172 } 161 173 else … … 168 180 elseif( PG4WP_DEBUG || PG4WP_ERROR_LOG) 169 181 { 170 if( PG4WP_DEBUG)171 $lastq = $GLOBALS['pg4wp_last_insert'];172 else173 $lastq = 'UNKNOWN';174 182 $log = '['.microtime(true)."] wpsql_insert_id() was called with '$table' and '$ins_field'". 175 183 " and generated an error. The latest INSERT query was :\n'$lastq'\n"; … … 455 463 $GLOBALS['pg4wp_ins_field'] = trim($match_list[4],' () '); 456 464 } 457 if( PG4WP_DEBUG) 458 $GLOBALS['pg4wp_last_insert'] = $sql; 465 $GLOBALS['pg4wp_last_insert'] = $sql; 466 } 467 elseif( isset($GLOBALS['pg4wp_queued_query'])) 468 { 469 pg_query($GLOBALS['pg4wp_queued_query']); 470 unset($GLOBALS['pg4wp_queued_query']); 459 471 } 460 472
Note: See TracChangeset
for help on using the changeset viewer.