Advertisement
carbonize

Like Installer

Nov 16th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. // Install like database tables
  3.  
  4. // Lets grab the database info
  5. define('LAZ_INCLUDE_PATH', dirname(__FILE__));
  6. require_once LAZ_INCLUDE_PATH.'/admin/config.inc.php';
  7.  
  8. //
  9. // Now we connect to the MySQL server and select the database
  10. //
  11.  
  12. if ($dbc = @mysql_connect ($GB_DB['host'], $GB_DB['user'], $GB_DB['pass']))
  13. {
  14.   if (!@mysql_select_db ($GB_DB['dbName'], $dbc))
  15.   {
  16.     die ('<p>Could not select the database because: <b>'.mysql_error().'</b></p></div></body></html>');
  17.   }
  18. }
  19. else
  20. {
  21.   die ('<p>Could not connect to MySQL because: <b>'.mysql_error().'</b></p></div></body></html>');
  22. }
  23.  
  24. //
  25. // End of MySQL database information check
  26. //
  27.  
  28. // Set the prefix for the table names
  29. define('LAZ_TABLE_PREFIX', $table_prefix);
  30.  
  31. $sqlQuery[] = "CREATE TABLE " . LAZ_TABLE_PREFIX . "_likes (
  32.  `id` smallint(10) NOT NULL AUTO_INCREMENT,
  33.  `ip` varchar(30) NOT NULL DEFAULT '',
  34.  `likedid` int(10) NOT NULL DEFAULT 0,
  35.  `time` int(11) NOT NULL DEFAULT 0,
  36.  PRIMARY KEY (`id`),
  37.  INDEX(`liked`)
  38. )";
  39.  
  40. $sqlQuery[] = "ALTER TABLE " . LAZ_TABLE_PREFIX . "_data (
  41.  ADD likes int(10) NOT NULL DEFAULT 0'
  42. )";
  43.  
  44. for($i=0; $i<sizeof($sqlQuery); $i++)
  45. {
  46.   if(!mysql_query($sqlquery[$i],$dbc))
  47.   {
  48.     die("Encountered an error updating the tables");
  49.   }
  50. }
  51.  
  52. echo 'Tables successfully created/updated. Please delete this file.';
  53. ?>
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement