2013062200-1.9.0_dev-new_remember_me_table-da1bfc6f36c7952e.php 929 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Elgg 1.9.0-dev upgrade 2013062200
  4. * new_remember_me_table
  5. *
  6. * Moves the remember code into the new table and then drops the code from
  7. * the users entity table
  8. */
  9. $db_prefix = elgg_get_config('dbprefix');
  10. // create remember me table
  11. $query1 = <<<SQL
  12. CREATE TABLE IF NOT EXISTS `{$db_prefix}users_remember_me_cookies` (
  13. `code` varchar(32) NOT NULL,
  14. `guid` bigint(20) unsigned NOT NULL,
  15. `timestamp` int(11) unsigned NOT NULL,
  16. PRIMARY KEY (`code`),
  17. KEY `timestamp` (`timestamp`)
  18. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  19. SQL;
  20. update_data($query1);
  21. // move codes
  22. $time = time();
  23. $query2 = <<<SQL
  24. INSERT INTO {$db_prefix}users_remember_me_cookies (`code`, `guid`, `timestamp`)
  25. SELECT `code`, `guid`, $time
  26. FROM {$db_prefix}users_entity
  27. WHERE `code` != ''
  28. SQL;
  29. update_data($query2);
  30. // drop code from users table
  31. $query3 = "ALTER TABLE {$db_prefix}users_entity DROP `code`";
  32. update_data($query3);