Ignore:
Timestamp:
Apr 13, 2019, 8:05:15 PM (5 years ago)
Author:
roby
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/funzioni.php

    r242 r265  
    259259     
    260260 
    261         $res = mysql_query("select *  from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ",$dbi);
    262        
    263         if ($res) $numero=mysql_num_rows($res);else $numero=0;
    264         $res = mysql_query("select t2.*  from ".$prefix."_ele_sezioni as t2, ".$prefix."_ele_sede as t1 where t2.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circondt1",$dbi);
    265         if ($res) $sezioni=mysql_num_rows($res);else $sezioni=0;
     261        $sql="select *  from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
     262        $res = $dbi->prepare("$sql");
     263        $res->execute();
     264
     265       
     266        if ($res) $numero=$res->rowCount();else $numero=0;
     267        $sql="select t2.*  from ".$prefix."_ele_sezioni as t2, ".$prefix."_ele_sede as t1 where t2.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circondt1";
     268        $res = $dbi->prepare("$sql");
     269        $res->execute();
     270
     271        if ($res) $sezioni=$res->rowCount();else $sezioni=0;
    266272        if ($numero>0){
    267273                if ($genere!=0){
    268                         $restotv = mysql_query("select sum(voti)  from ".$prefix."_$tab where id_cons='$id_cons' ",  $dbi);
    269                         list($tot)  = mysql_fetch_row($restotv);
     274                        $sql="select sum(voti)  from ".$prefix."_$tab where id_cons='$id_cons' ";
     275        $restotv = $dbi->prepare("$sql");
     276        $restotv->execute();
     277 
     278                        list($tot)  = $restotv->fetch(PDO::FETCH_NUM);
    270279                        $i=0;
    271280                        // lista o gruppo
    272281                        if ($genere!=4){
    273282                                if ($votog){
    274                                         $res = mysql_query("select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
     283                                        $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
    275284                                        from ".$prefix."_ele_gruppo as t1,
    276285                                        ".$prefix."_ele_voti_lista as t2,
     
    280289                                        and t1.id_gruppo=t3.id_gruppo
    281290                                        group by t1.id_gruppo
    282                                         order by somma desc", $dbi);
     291                                        order by somma desc";
    283292                                }else{
    284                                 $res = mysql_query("select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
     293                                $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
    285294                                        from ".$prefix."_ele_gruppo as t1
    286295                                left join ".$prefix."_ele_voti_gruppo as t2 on (t1.id_gruppo=t2.id_gruppo)
    287296                                        where   t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
    288297                                        group by t2.id_gruppo
    289                                         order by somma desc", $dbi);
     298                                        order by somma desc";
    290299                            }
    291300                        }else{
    292                                 $res = mysql_query("select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
     301                                $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
    293302                                from ".$prefix."_ele_lista as t1
    294303                        left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
    295304                                where   t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons
    296305                                group by t2.id_lista
    297                                 order by somma desc", $dbi);
     306                                order by somma desc";
    298307                        }
    299                                 $gruppinum=mysql_num_rows($res);
     308                                $res = $dbi->prepare("$sql");
     309                                $res->execute();
     310                                $gruppinum=$res->rowCount();
    300311                                $altrivoti=0;
    301312###### gestione percentuali
     
    303314                                $arval=array();
    304315                                $arvaltot=0;
    305                                 while (list($id,$num,$descrizione,$voti)  = mysql_fetch_row($res)){
     316                                while (list($id,$num,$descrizione,$voti)  = $res->fetch(PDO::FETCH_NUM)){
    306317                                        $arval[$id]=$voti;
    307318                                        $arvaltot+=$voti;
    308319                                }
    309320                                $arperc=arrayperc($arval,$arvaltot);
    310                                 mysql_data_seek($res,0);
    311                                 while (list($id,$num,$descrizione,$voti)  = mysql_fetch_row($res)){
     321                                $res = $dbi->prepare("$sql");
     322                                $res->execute();
     323                                while (list($id,$num,$descrizione,$voti)  = $res->fetch(PDO::FETCH_NUM)){
    312324                                        // funz per il taglio corretto della frase 13 feb 2007
    313325                                        $descrizione=substr($descrizione,0,20);
     
    366378        if($pos=="dx") $p=0; elseif($pos=="sx")$p=1;else $p='';
    367379       
    368         $resblk = mysql_query("SELECT * FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc", $dbi);
    369         if($resblk){
    370                 while ($row = mysql_fetch_array($resblk)) {
     380        $sql="SELECT * FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc";
     381        $res = $dbi->prepare("$sql");
     382        $res->execute();
     383        if($res->rowCount()){
     384                while ($row = $res->fetch(PDO::FETCH_BOTH)) {
    371385                $nome=$row['nome_file'];
    372386                include ("modules/Elezioni/blocchi/$nome");
     
    380394if($pos=="dx") $p=0; elseif($pos=="sx")$p=1;else $p='';
    381395       
    382         $reschk = mysql_query("SELECT * FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc", $dbi);
    383         if ($reschk) $numero=mysql_num_rows($reschk);else $numero=0;   
     396        $sql="SELECT * FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc";
     397        $res = $dbi->prepare("$sql");
     398        $res->execute();
     399        if ($res) $numero=$res->rowCount();else $numero=0;     
    384400
    385401                return  $numero;
     
    436452        }else{
    437453
    438                 $res = mysql_query("SELECT simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
    439                 list($simbolo,$stemma) = mysql_fetch_row($res);
     454                $sql="SELECT simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
     455        $res = $dbi->prepare("$sql");
     456        $res->execute();
     457                list($simbolo,$stemma) = $res->fetch(PDO::FETCH_NUM);
    440458                if($simbolo!=''){
    441459                        if (!file_exists("modules/Elezioni/images/$simbolo")) {
     
    461479global $prefix,$dbi,$id_cons,$limite,$fascia,$ops;
    462480        #voti di lista e di gruppo completamente disgiunti
    463         $result = mysql_query("select infdisgiunto, supdisgiunto from ".$prefix."_ele_conf as t2 left join ".$prefix."_ele_cons_comune as t1 on t1.id_conf=t2.id_conf where id_cons = '$id_cons' ", $dbi);
     481        $sql="select infdisgiunto, supdisgiunto from ".$prefix."_ele_conf as t2 left join ".$prefix."_ele_cons_comune as t1 on t1.id_conf=t2.id_conf where id_cons = '$id_cons' ";
     482        $result = $dbi->prepare("$sql");
     483        $result->execute();
    464484        $glsep='';
    465485        if ($result) {
    466                 list($infdis,$supdis)=mysql_fetch_row($result);
     486                list($infdis,$supdis)=$result->fetch(PDO::FETCH_NUM);
    467487                if((($fascia>$limite and $supdis) or ($fascia<$limite and $infdis)) and $ops==3)
    468488                        $glsep='_lista';
Note: See TracChangeset for help on using the changeset viewer.