Location: PHPKode > projects > Esvon Personals > esvon-personals/upgrades/v3_to_v4/upgrade314-315.php
<?php

// File to upgrade Esvon Classifieds from 3.0.793 to 3.0.794
// After use this, you can delete it

//*********************************************

define('DB_UPGRADE', 1);

if(!defined('SITE_PATH')){
  if(!file_exists('./inc/application.php')) die("File Not Found: application.php");
  require_once './inc/application.php';
}
 
if(hwModGetState('Availability')){
  mysql_query("ALTER TABLE ".TBL_AD." ADD hw_av_disabled tinyint(3) NOT NULL");
}

$db->query('UPDATE '.TBL_FIELD.' SET extra = "\nNo\nYes" WHERE db_f = "hw_sold" AND extra = "No\nYes"');

mysql_query("ALTER TABLE ".TBL_FIELD." ADD editable char(1) NOT NULL");

if(hwModGetState('Mailing_Lists')){
  mysql_query("INSERT INTO ".hwModTable('Mailing_Lists','idx')." VALUES ('-2', 'Members with Ads', '', '')");
  mysql_query("ALTER TABLE ".hwModTable('Mailing_Lists','temp')." ADD temp char(1) NOT NULL");

/*
  $tbl = hwModTable('Mailing_Lists','list');
  mysql_query("ALTER TABLE ".$tbl." DROP PRIMARY KEY");
  mysql_query("ALTER TABLE ".$tbl." ADD COLUMN `id` INTEGER(11) UNSIGNED NOT NULL");
  if($db->one_data("SELECT COUNT(*) FROM ".$tbl." WHERE id = 0")){
    $res = $db->query("SELECT * FROM ".$tbl);
    $i = 0;
    while($v = mysql_fetch_assoc($res)){
      $db->query("UPDATE $tbl SET id='".(++$i)."' WHERE list_id='{$v['list_id']}' AND email='{$v['email']}'");
    }
  }
  mysql_query("ALTER TABLE ".$tbl." MODIFY COLUMN `id` INTEGER(11) UNSIGNED NOT NULL DEFAULT '0' AUTO_INCREMENT PRIMARY KEY");
  mysql_query("ALTER TABLE ".$tbl." ADD UNIQUE `list_id` (`list_id`, `email`)");

  mysql_query("CREATE TABLE ".hwModTable('Mailing_Lists','temp')." ( 
    log_id int(11) unsigned NOT NULL, email varchar(50) NOT NULL, extra text NOT NULL,
    temp char(1) NOT NULL, PRIMARY KEY (log_id, email)) ");

  mysql_query("ALTER TABLE ".hwModTable('Mailing_Lists','log')." ADD (extra text NOT NULL)");

*/

}

if(hwModGetState('Auction')){
  mysql_query("CREATE TABLE ".hwModTable('Auction','note')." (
   id int(11) unsigned NOT NULL auto_increment,
   lid mediumint(8) unsigned DEFAULT '0' NOT NULL,
   cdate datetime NOT NULL,
   descr text NOT NULL,
   PRIMARY KEY (id))");
}

$db->query('UPDATE '.TBL_AD.' SET hw_sold = "1" WHERE hw_sold="Yes"');
$db->query('UPDATE '.TBL_AD.' SET hw_sold = "0" WHERE hw_sold="No"');

$db->query('UPDATE '.TBL_FIELD.' SET type="checkbox", extra="" WHERE id="hw_sold"');

if(hwModGetState('Auction')){
  $MOD_CFG = $O_HW->GetModOptions('Auction');
  $a_fs = explode(',', $MOD_CFG['FS'] ? $MOD_CFG['FS'] : 'auction');
  $db->query('SET @list := ""');
  $db->query('SELECT @list := CONCAT(@list, id, ",") FROM '.TBL_CAT.' WHERE fset IN("'.implode('","',$a_fs).'")');
  $db->query('SET @list = IF(LENGTH(@list)=0,"",LEFT(@list,LENGTH(@list)-1))');
  $db->query('UPDATE '.TBL_AD.' SET hw_auct_closed="N" WHERE FIND_IN_SET(catid,@list) > 0 AND hw_auct_closed=""');
  $db->query('SET @list := ""');
}

echo 'Esvon Classifieds Tables Updated, Ok.. ('.basename(__FILE__).')';


?>
Return current item: Esvon Personals