[296] | 1 | <?php
|
---|
[324] | 2 |
|
---|
[338] | 3 | #implementare controllo con: SHOW INDEX FROM tua_tabella WHERE tua_tabella.tua_colonna='nome_colonna';
|
---|
[296] | 4 | @require_once("config.php");
|
---|
| 5 | try{
|
---|
| 6 | $dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
|
---|
| 7 | $sql = "use $dbname";
|
---|
| 8 | $dbi->exec($sql);
|
---|
| 9 | }
|
---|
| 10 | catch(PDOException $e)
|
---|
| 11 | {
|
---|
| 12 | die( $sql . "<br>" . $e->getMessage());
|
---|
| 13 | }
|
---|
| 14 | ###############
|
---|
[357] | 15 | function aggiorna($sql,$dbi,$sql2,$num){
|
---|
[330] | 16 | $ret=0;
|
---|
[296] | 17 | try{
|
---|
| 18 | $res = $dbi->prepare("$sql");
|
---|
| 19 | $res->execute();
|
---|
[330] | 20 | $ret= 1;
|
---|
[296] | 21 | }
|
---|
| 22 | catch(PDOException $e)
|
---|
| 23 | {
|
---|
[330] | 24 | $ret=0;
|
---|
[357] | 25 | echo "<br>".$num.") Fallito: $sql";
|
---|
| 26 | return $ret;
|
---|
[330] | 27 | }
|
---|
| 28 |
|
---|
| 29 | if("$sql2"!=""){
|
---|
| 30 | try{
|
---|
| 31 | $res = $dbi->prepare("$sql2");
|
---|
| 32 | $res->execute();
|
---|
| 33 | $ret=2;
|
---|
| 34 | }
|
---|
| 35 | catch(PDOException $e)
|
---|
| 36 | {
|
---|
| 37 | $ret=0;
|
---|
[357] | 38 | echo "<br>".$num.") Fallito: $sql2";
|
---|
| 39 | return $ret;
|
---|
[330] | 40 | }
|
---|
[296] | 41 | }
|
---|
[357] | 42 | echo "<br>".$num.") Aggiornato<br>";
|
---|
[330] | 43 | return $ret;
|
---|
[324] | 44 | }
|
---|
[359] | 45 | function aggiorna_index($tab,$ind,$dbi,$sql2,$num){
|
---|
[357] | 46 | $ret=0;
|
---|
[359] | 47 | $sqltest="SHOW INDEX FROM `$tab` WHERE KEY_NAME = '$ind'";
|
---|
| 48 | $res = $dbi->prepare("$sqltest");
|
---|
| 49 | $res->execute();
|
---|
| 50 | if($res->rowCount()) {
|
---|
| 51 | $sql="ALTER TABLE `$tab` DROP INDEX `$ind`";
|
---|
| 52 | try{
|
---|
| 53 | $res = $dbi->prepare("$sql");
|
---|
| 54 | $res->execute();
|
---|
| 55 | $ret= 1;
|
---|
| 56 | }
|
---|
| 57 | catch(PDOException $e)
|
---|
| 58 | {
|
---|
| 59 | $ret=0;
|
---|
| 60 | echo "<br>".$num.") Fallito: $sql -- $e->getmessage()";
|
---|
| 61 | return $ret;
|
---|
| 62 | }
|
---|
[357] | 63 | }
|
---|
| 64 | if("$sql2"!=""){
|
---|
| 65 | try{
|
---|
| 66 | $res = $dbi->prepare("$sql2");
|
---|
| 67 | $res->execute();
|
---|
| 68 | $ret=2;
|
---|
| 69 | }
|
---|
| 70 | catch(PDOException $e)
|
---|
| 71 | {
|
---|
| 72 | $ret=0;
|
---|
| 73 | echo "<br>".$num.") Fallito: $sql2";
|
---|
| 74 | return $ret;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | echo "<br>".$num.") Index aggiornato<br>";
|
---|
| 78 | return $ret;
|
---|
| 79 | }
|
---|
[324] | 80 |
|
---|
[357] | 81 |
|
---|
| 82 | $num=0;
|
---|
| 83 |
|
---|
| 84 | function controllo($tabella,$campo,$num)
|
---|
| 85 | {
|
---|
| 86 | global $dbi, $dbname;
|
---|
| 87 | $sql="SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbname' AND TABLE_NAME = '$tabella'";
|
---|
| 88 | $res = $dbi->prepare("$sql");
|
---|
| 89 | $res->execute();
|
---|
| 90 | if($res->rowCount() and $campo=='') return 1;
|
---|
| 91 | while(list($nome)=$res->fetch(PDO::FETCH_NUM)) {if($nome==$campo) { echo "<br>".$num.") Aggiornamento già effettuato<br>"; return 1;}}
|
---|
| 92 | return 0;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[324] | 95 | $sql="SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '$dbname' AND COLUMN_NAME = 'Versione'";
|
---|
[357] | 96 | $res = $dbi->prepare("$sql");
|
---|
| 97 | $res->execute();
|
---|
| 98 |
|
---|
| 99 | if(!controllo($prefix.'_config','versione',++$num))
|
---|
[324] | 100 | {
|
---|
[357] | 101 | $sql="alter table `".$prefix."_config` change column `Versione` `versione` int(3)";
|
---|
| 102 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
[296] | 103 | }
|
---|
| 104 |
|
---|
[357] | 105 | if(!controllo($prefix.'_ele_gruppo','num_circ',++$num))
|
---|
| 106 | {
|
---|
| 107 | $sql="ALTER TABLE `".$prefix."_ele_gruppo` ADD `num_circ` INT(2) UNSIGNED NOT NULL AFTER `id_circ`";
|
---|
| 108 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 109 | # if(!$ret) echo "<br>".$num.") Fallito: $sql"; else echo "<br>".$num.") Aggiornato<br>";
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | if(!controllo($prefix.'_ele_voti_gruppo','num_gruppo',++$num))
|
---|
| 113 | {
|
---|
| 114 | $sql="ALTER TABLE `".$prefix."_ele_voti_gruppo` ADD `num_gruppo` INT(2) UNSIGNED NOT NULL AFTER `id_sez`";
|
---|
| 115 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | if(!controllo($prefix.'_ele_lista','num_gruppo',++$num))
|
---|
| 119 | {
|
---|
| 120 | $sql="ALTER TABLE `".$prefix."_ele_lista` ADD `num_gruppo` INT(2) UNSIGNED NOT NULL AFTER `id_gruppo`";
|
---|
| 121 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | if(!controllo($prefix.'_ele_lista','num_circ',++$num))
|
---|
| 125 | {
|
---|
| 126 | $sql="ALTER TABLE `".$prefix."_ele_lista` ADD `num_circ` INT(2) UNSIGNED NOT NULL AFTER `id_circ`";
|
---|
| 127 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 128 | }
|
---|
[358] | 129 | if(!controllo($prefix.'_ele_operatori','id_circ',++$num))
|
---|
| 130 | {
|
---|
| 131 | $sql="ALTER TABLE `".$prefix."_ele_operatori` ADD `id_circ` INT(11) NOT NULL DEFAULT 0 AFTER `aid`";
|
---|
| 132 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 133 | }
|
---|
[359] | 134 | if(!controllo($prefix.'_ele_operatori','id_sez',++$num))
|
---|
[358] | 135 | {
|
---|
| 136 | $sql="ALTER TABLE `".$prefix."_ele_operatori` ADD `id_sez` INT(11) NOT NULL DEFAULT 0 AFTER `id_circ`";
|
---|
| 137 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 138 | }
|
---|
[357] | 139 | if(!controllo($prefix.'_ele_voti_lista','num_lista',++$num))
|
---|
| 140 | {
|
---|
| 141 | $sql="ALTER TABLE `".$prefix."_ele_voti_lista` ADD `num_lista` INT(2) UNSIGNED NOT NULL AFTER `id_sez`";
|
---|
| 142 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | if(!controllo($prefix.'_ele_voti_ref','num_gruppo',++$num))
|
---|
| 146 | {
|
---|
| 147 | $sql="ALTER TABLE `".$prefix."_ele_voti_ref` ADD `num_gruppo` INT(2) UNSIGNED NOT NULL AFTER `id_sez`";
|
---|
| 148 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | if(!controllo($prefix.'_ele_voti_candidati','num_cand',++$num))
|
---|
| 152 | {
|
---|
| 153 | $sql="ALTER TABLE `".$prefix."_ele_voti_candidati` ADD `num_cand` INT(2) UNSIGNED NOT NULL AFTER `id_sez`";
|
---|
| 154 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | if(!controllo($prefix.'_ele_candidati','num_lista',++$num))
|
---|
| 158 | {
|
---|
| 159 | $sql="ALTER TABLE `".$prefix."_ele_candidati` ADD `num_lista` INT(2) UNSIGNED NOT NULL AFTER `id_lista`";
|
---|
| 160 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | if(!controllo($prefix.'_ele_sezioni','colore',++$num))
|
---|
| 164 | {
|
---|
| 165 | $sql="ALTER TABLE `".$prefix."_ele_sezioni` ADD `colore` VARCHAR(50) NULL AFTER `solo_lista`";
|
---|
| 166 | $ret=aggiorna($sql,$dbi,$sql2,$num);
|
---|
| 167 | }
|
---|
| 168 | echo "<br>Aggiornamento per nuovo sistema dei controlli di congruità ";
|
---|
| 169 |
|
---|
| 170 | if(!controllo($prefix.'_ele_controlli','id_cons',++$num))
|
---|
| 171 | {
|
---|
| 172 | $sql="CREATE TABLE if not exists`".$prefix."_ele_controlli` ( `id_cons` INT(11) NOT NULL , `id_sez` INT(11) NOT NULL , `tipo` VARCHAR(10) NOT NULL , `id` INT(11) NOT NULL , INDEX `sezione` (`id_sez`)) ENGINE = MyISAM";
|
---|
| 173 | echo "<br>".$num.") Creazione tabella dei controlli: ";
|
---|
| 174 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | echo "<br>Eliminazione della vecchia tabella dei controlli: ";
|
---|
| 178 | if(controllo($prefix.'_ele_controllisez','',++$num))
|
---|
| 179 | {
|
---|
| 180 | $sql="DROP TABLE if exists `".$prefix."_ele_controllisez`";
|
---|
| 181 | $ret=aggiorna($sql,$dbi,'',$num);
|
---|
| 182 | } else echo "<br>$num) Tabella non presente<br>";
|
---|
| 183 |
|
---|
| 184 | $sql="update `".$prefix."_ele_voti_gruppo` as t1 left join `".$prefix."_ele_gruppo` as t2 on t1.id_gruppo=t2.id_gruppo set t1.num_gruppo=t2.num_gruppo;";
|
---|
| 185 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 186 |
|
---|
| 187 | $sql="update `".$prefix."_ele_voti_lista` as t1 left join `".$prefix."_ele_lista` as t2 on t1.id_lista=t2.id_lista set t1.num_lista=t2.num_lista;";
|
---|
| 188 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 189 | ##############################################
|
---|
| 190 |
|
---|
| 191 | $sql="ALTER TABLE `".$prefix."_ele_gruppo` CHANGE `num_circ` `num_circ` INT(2) UNSIGNED NOT NULL DEFAULT '1';";
|
---|
| 192 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 193 |
|
---|
[359] | 194 | $sql="ALTER TABLE `soraldo_authors` CHANGE `adminsuper` `adminsuper` TINYINT(2) NOT NULL DEFAULT '0';";
|
---|
| 195 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 196 |
|
---|
[357] | 197 | $sql="ALTER TABLE `".$prefix."_ele_lista` CHANGE `num_gruppo` `num_gruppo` INT(2) UNSIGNED NOT NULL DEFAULT '0';";
|
---|
| 198 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 199 |
|
---|
| 200 | $sql="ALTER TABLE `".$prefix."_ele_lista` CHANGE `num_circ` `num_circ` INT(2) UNSIGNED NOT NULL DEFAULT '1';";
|
---|
| 201 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 202 |
|
---|
| 203 | $sql="DROP TABLE `".$prefix."_ele_fasce`";
|
---|
| 204 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 205 |
|
---|
| 206 | $sql="CREATE TABLE `".$prefix."_ele_fasce` (
|
---|
| 207 | `id_fascia` int(2) NOT NULL,
|
---|
| 208 | `abitanti` int(11) NOT NULL,
|
---|
| 209 | `seggi` int(4) NOT NULL,
|
---|
| 210 | `id_conf` int(11) DEFAULT 1
|
---|
| 211 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 | $sql2="INSERT INTO `".$prefix."_ele_fasce` (`id_fascia`, `abitanti`, `seggi`, `id_conf`) VALUES
|
---|
| 215 | (1, 3000, 12, 1),
|
---|
| 216 | (2, 10000, 16, 1),
|
---|
| 217 | (3, 15000, 20, 1),
|
---|
| 218 | (4, 30000, 20, 1),
|
---|
| 219 | (5, 100000, 30, 1),
|
---|
| 220 | (6, 250000, 40, 1),
|
---|
| 221 | (7, 500000, 46, 1),
|
---|
| 222 | (8, 1000000, 50, 1),
|
---|
| 223 | (9, 100000000, 60, 1),
|
---|
| 224 | (1, 3000, 12, 2),
|
---|
| 225 | (2, 10000, 16, 2),
|
---|
| 226 | (3, 15000, 20, 2),
|
---|
| 227 | (4, 30000, 20, 2),
|
---|
| 228 | (5, 100000, 30, 2),
|
---|
| 229 | (6, 250000, 40, 2),
|
---|
| 230 | (7, 500000, 46, 2),
|
---|
| 231 | (8, 1000000, 50, 2),
|
---|
| 232 | (9, 100000000, 60, 2),
|
---|
| 233 | (1, 3000, 9, 3),
|
---|
| 234 | (2, 5000, 9, 3),
|
---|
| 235 | (4, 15000, 16, 3),
|
---|
| 236 | (3, 10000, 12, 3),
|
---|
| 237 | (5, 30000, 16, 3),
|
---|
| 238 | (6, 100000, 24, 3),
|
---|
| 239 | (7, 250000, 32, 3),
|
---|
| 240 | (8, 500000, 36, 3),
|
---|
| 241 | (9, 1000000, 40, 3),
|
---|
| 242 | (10, 100000000, 48, 3),
|
---|
| 243 | (1, 3000, 6, 4),
|
---|
| 244 | (2, 5000, 7, 4),
|
---|
| 245 | (3, 10000, 12, 4),
|
---|
| 246 | (4, 15000, 16, 4),
|
---|
| 247 | (5, 30000, 16, 4),
|
---|
| 248 | (6, 100000, 24, 4),
|
---|
| 249 | (7, 250000, 32, 4),
|
---|
| 250 | (8, 500000, 36, 4),
|
---|
| 251 | (9, 1000000, 40, 4),
|
---|
| 252 | (10, 100000000, 48, 4),
|
---|
| 253 | (1, 3000, 9, 5),
|
---|
| 254 | (2, 5000, 9, 5),
|
---|
| 255 | (3, 10000, 12, 5),
|
---|
| 256 | (4, 15000, 16, 5),
|
---|
| 257 | (5, 30000, 16, 5),
|
---|
| 258 | (6, 100000, 24, 5),
|
---|
| 259 | (7, 250000, 32, 5),
|
---|
| 260 | (8, 500000, 36, 5),
|
---|
| 261 | (9, 1000000, 40, 5),
|
---|
| 262 | (10, 100000000, 48, 5),
|
---|
| 263 | (1, 3000, 6, 6),
|
---|
| 264 | (2, 5000, 7, 6),
|
---|
| 265 | (3, 10000, 10, 6),
|
---|
| 266 | (4, 15000, 16, 6),
|
---|
| 267 | (5, 30000, 16, 6),
|
---|
| 268 | (6, 100000, 24, 6),
|
---|
| 269 | (7, 250000, 32, 6),
|
---|
| 270 | (8, 500000, 36, 6),
|
---|
| 271 | (9, 1000000, 40, 6),
|
---|
| 272 | (10, 100000000, 48, 6),
|
---|
| 273 | (1, 3000, 10, 7),
|
---|
| 274 | (2, 10000, 12, 7),
|
---|
| 275 | (3, 15000, 16, 7),
|
---|
| 276 | (4, 30000, 16, 7),
|
---|
| 277 | (5, 100000, 24, 7),
|
---|
| 278 | (6, 250000, 32, 7),
|
---|
| 279 | (7, 500000, 36, 7),
|
---|
| 280 | (8, 1000000, 40, 7),
|
---|
| 281 | (9, 100000000, 48, 7);";
|
---|
| 282 | $ret=aggiorna($sql,$dbi,$sql2,++$num);
|
---|
[324] | 283 | #if(!$ret) echo "<br>".$num++.") Fallito: $sql"; else echo "<br>".$num++.") Aggiornato<br>";
|
---|
[296] | 284 |
|
---|
[357] | 285 | $sql="ALTER TABLE `".$prefix."_ele_fasce`
|
---|
| 286 | ADD KEY `id_fascia` (`id_fascia`);";
|
---|
| 287 | $ret=aggiorna($sql,$dbi,'',++$num);
|
---|
| 288 | #if(!$ret) echo "<br>".$num++.") Fallito: $sql"; else echo "<br>".$num++.") Aggiornato<br>";
|
---|
| 289 |
|
---|
| 290 |
|
---|
| 291 |
|
---|
| 292 | #if(!$ret)
|
---|
| 293 | # echo "<br>".$num++.") Fallito: $sql";
|
---|
| 294 | #elseif ($ret==1)
|
---|
| 295 | # echo "<br>".$num++.") Index eliminato";
|
---|
| 296 | #else
|
---|
| 297 | # echo "<br>".$num++.") Index aggiunto";
|
---|
[359] | 298 | #$sql="ALTER TABLE `".$prefix."_ele_voti_lista` DROP INDEX if exists `id_cons`";
|
---|
| 299 |
|
---|
| 300 | $tab=$prefix."_ele_voti_ref";
|
---|
| 301 | $ind="id_cons";
|
---|
| 302 | # $sql="ALTER TABLE `".$prefix."_ele_voti_ref` DROP INDEX `id_cons`; ";
|
---|
| 303 | $sql2="ALTER TABLE `".$prefix."_ele_voti_ref` ADD INDEX `id_cons` (`id_cons`, `id_gruppo`) USING BTREE";
|
---|
| 304 | $ret=aggiorna_index($tab, $ind,$dbi,$sql2,++$num);
|
---|
| 305 |
|
---|
| 306 | $tab=$prefix."_ele_voti_lista";
|
---|
| 307 | $ind="id_cons";
|
---|
[357] | 308 | $sql2="ALTER TABLE `".$prefix."_ele_voti_lista` ADD INDEX `id_cons` (`id_cons`, `id_sez`, `id_lista`) USING BTREE";
|
---|
[359] | 309 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 310 |
|
---|
[359] | 311 | $tab=$prefix."_ele_voti_gruppo";
|
---|
| 312 | $ind="id_cons";
|
---|
| 313 | #$sql="ALTER TABLE `".$prefix."_ele_voti_gruppo` DROP INDEX if exists `id_cons`";
|
---|
[357] | 314 | $sql2="ALTER TABLE `".$prefix."_ele_voti_gruppo` ADD INDEX `id_cons` (`id_cons`, `id_sez`, `id_gruppo`) USING BTREE";
|
---|
[359] | 315 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 316 |
|
---|
[359] | 317 | $tab=$prefix."_ele_voti_candidati";
|
---|
| 318 | $ind="id_cons";
|
---|
| 319 | #$sql="ALTER TABLE `".$prefix."_ele_voti_candidati` DROP INDEX if exists `id_cons`";
|
---|
[357] | 320 | $sql2="ALTER TABLE `".$prefix."_ele_voti_candidati` ADD INDEX `id_cons` (`id_cons`, `id_sez`, `id_cand`) USING BTREE";
|
---|
[359] | 321 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 322 |
|
---|
[359] | 323 | $tab=$prefix."_ele_lista";
|
---|
| 324 | $ind="id_cons";
|
---|
| 325 | #$sql="ALTER TABLE `".$prefix."_ele_lista` DROP INDEX if exists `id_cons`";
|
---|
[357] | 326 | $sql2="ALTER TABLE `".$prefix."_ele_lista` ADD INDEX `id_cons` (`id_cons`, `id_gruppo`) USING BTREE";
|
---|
[359] | 327 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 328 |
|
---|
[359] | 329 | $tab=$prefix."_ele_lista";
|
---|
| 330 | $ind="PRIMARY";
|
---|
| 331 | #$sql="ALTER TABLE `".$prefix."_ele_lista` DROP INDEX if exists `PRIMARY`";
|
---|
[357] | 332 | $sql2="ALTER TABLE `".$prefix."_ele_lista` ADD PRIMARY KEY (`id_lista`) USING BTREE";
|
---|
[359] | 333 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 334 |
|
---|
[359] | 335 | $tab=$prefix."_ele_gruppo";
|
---|
| 336 | $ind="id_cons";
|
---|
| 337 | #$sql="ALTER TABLE `".$prefix."_ele_gruppo` DROP INDEX if exists `id_cons`";
|
---|
[357] | 338 | $sql2="ALTER TABLE `".$prefix."_ele_gruppo` ADD INDEX `id_cons` (`id_cons`, `id_circ`) USING BTREE";
|
---|
[359] | 339 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 340 |
|
---|
[359] | 341 | $tab=$prefix."_ele_gruppo";
|
---|
| 342 | $ind="PRIMARY";
|
---|
| 343 | #$sql="ALTER TABLE `".$prefix."_ele_gruppo` DROP INDEX if exists `PRIMARY`";
|
---|
[357] | 344 | $sql2="ALTER TABLE `".$prefix."_ele_gruppo` ADD PRIMARY KEY (`id_gruppo`) USING BTREE";
|
---|
[359] | 345 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 346 |
|
---|
[359] | 347 | $tab=$prefix."_ele_candidati";
|
---|
| 348 | $ind="id_cons";
|
---|
| 349 | #$sql="ALTER TABLE `".$prefix."_ele_candidati` DROP INDEX if exists `id_cons`";
|
---|
[357] | 350 | $sql2="ALTER TABLE `".$prefix."_ele_candidati` ADD INDEX `id_cons` (`id_cons`, `id_lista`) USING BTREE";
|
---|
[359] | 351 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 352 |
|
---|
[359] | 353 | $tab=$prefix."_ele_candidati";
|
---|
| 354 | $ind="PRIMARY";
|
---|
| 355 | #$sql="ALTER TABLE `".$prefix."_ele_candidati` DROP INDEX if exists `PRIMARY`";
|
---|
[357] | 356 | $sql2="ALTER TABLE `".$prefix."_ele_candidati` ADD PRIMARY KEY (`id_cand`) USING BTREE";
|
---|
[359] | 357 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 358 |
|
---|
[359] | 359 | $tab=$prefix."_ele_consultazione";
|
---|
| 360 | $ind="descrizione";
|
---|
| 361 | #$sql="ALTER TABLE `".$prefix."_ele_consultazione` DROP INDEX if exists `descrizione`";
|
---|
| 362 | $sql2="ALTER TABLE `".$prefix."_ele_consultazione` ADD UNIQUE `descrizione` (`descrizione`(100))";
|
---|
| 363 | $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
|
---|
[357] | 364 |
|
---|
[359] | 365 |
|
---|
[296] | 366 | ?>
|
---|