Skip to content

Instantly share code, notes, and snippets.

@rjmackay
Created July 24, 2012 22:34
Show Gist options
  • Save rjmackay/3173122 to your computer and use it in GitHub Desktop.
Save rjmackay/3173122 to your computer and use it in GitHub Desktop.
Better table prefix handling in Upgrader
@ -319,19 +319,25 @@ class Upgrade_Controller extends Admin_Controller {
if ($table_prefix)
{
$find = array(
'CREATE TABLE IF NOT EXISTS `',
'INSERT INTO `',
+ 'INSERT IGNORE INTO `',
'ALTER TABLE `',
- 'UPDATE `'
+ 'UPDATE `',
+ 'DELETE FROM `',
+ 'LOCK TABLES `',
);
$replace = array(
- 'CREATE TABLE IF NOT EXISTS `'.$table_prefix.'_',
- 'INSERT INTO `'.$table_prefix.'_',
- 'ALTER TABLE `'.$table_prefix.'_',
- 'UPDATE `'.$table_prefix.'_'
+ 'CREATE TABLE IF NOT EXISTS `'.$table_prefix,
+ 'INSERT INTO `'.$table_prefix,
+ 'INSERT IGNORE INTO `'.$table_prefix,
+ 'ALTER TABLE `'.$table_prefix,
+ 'UPDATE `'.$table_prefix,
+ 'DELETE FROM `'.$table_prefix,
+ 'LOCK TABLES `'.$table_prefix,
);
$upgrade_schema = str_replace($find, $replace, $upgrade_schema);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment