Changeset 546689
- Timestamp:
- 05/20/2012 07:24:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postgresql-for-wordpress/trunk/pg4wp/driver_pgsql.php
r546644 r546689 314 314 if( false !== $pos = strpos( $sql, 'ON DUPLICATE KEY')) 315 315 { 316 // Remove 'ON DUPLICATE KEY UPDATE...' and following317 $sql = substr( $sql, 0, $pos);318 316 // Get the elements we need (table name, first field, corresponding value) 319 317 $pattern = '/INSERT INTO\s+([^\(]+)\(([^,]+)[^\(]+VALUES\s*\(([^,]+)/'; 320 318 preg_match($pattern, $sql, $matches); 321 $sql = 'DELETE FROM '.$matches[1].' WHERE '.$matches[2].' = '.$matches[3].';'.$sql; 319 $table = trim( $matches[1], ' `'); 320 if( !in_array(trim($matches[1],'` '), array($wpdb->posts,$wpdb->comments))) 321 { 322 // Remove 'ON DUPLICATE KEY UPDATE...' and following 323 $sql = substr( $sql, 0, $pos); 324 // Add a delete query to handle the maybe existing data 325 $sql = 'DELETE FROM '.$table.' WHERE '.$matches[2].' = '.$matches[3].';'.$sql; 326 } 322 327 } 323 328
Note: See TracChangeset
for help on using the changeset viewer.