phpDocumentor VFront
Function-Libraries
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file func.rpc_query.php

Documentation is available at func.rpc_query.php

  1. <?php
  2. /**
  3. * Libreria di funzioni RPC.
  4. * Queste funzioni sono richiamata tendenzialmente dal file {@link rpc.php} per eseguire
  5. * chiamate al database dalle maschere.
  6. * Sono presenti inoltre alcune funzioni di utilità.
  7. @package VFront
  8. @subpackage Function-Libraries
  9. @author Mario Marcello Verona <marcelloverona@gmail.com>
  10. @copyright 2007 Mario Marcello Verona
  11. @version 0.90
  12. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  13. */
  14.  
  15.  
  16.  
  17.  
  18. /**
  19.  * Funzione per la codifica in javascript di caratteri speciali nelle url
  20.  *
  21.  * @param string $str 
  22.  * @return string encoded
  23.  */
  24. function urldecode_js($str){
  25.     
  26.     $str=urldecode($str);
  27.     
  28.     $find=array("%u201C","%u201D",
  29.                 "%u2019",
  30.                 "%u2013");
  31.     
  32.     $replace=array("\"","\"",
  33.                     "\\'",
  34.                     "-");
  35.                     
  36.     return str_replace($find,$replace,$str);
  37.     
  38.     
  39. }
  40.  
  41.  
  42.  
  43. /**
  44.  * Funzione di modifica di un record.
  45.  * Restituisce l'SQL per la modifica
  46.  *
  47.  * @param array $_dati 
  48.  * @param array $_pk 
  49.  * @param string $tabella 
  50.  * @return string SQL
  51.  */
  52. function rpc_query_update($_dati,$_pk,$tabella=""){
  53.     
  54.     $sql "UPDATE $tabella SET ";
  55.     
  56.     foreach($_dati as $k=>$val){
  57.         
  58.         $val_hidden variabili_campi($val);
  59.         
  60.         if($val_hidden!=false){
  61.             $val=$val_hidden;
  62.         }
  63.         
  64.         $val=urldecode_js($val);
  65.         
  66.         $sql.="\n $k='".addslashes(stripslashes($val))."',";
  67.     }
  68.     
  69.     $sql substr($sql,0,-1);
  70.     
  71.     if(count($_pk)<=0){
  72.         return false;
  73.     }
  74.     else{
  75.         
  76.         $sql.="\n WHERE ";
  77.         
  78.         foreach($_pk as $k=>$val){
  79.             
  80.             
  81.                     
  82.             $sql.="$k='".addslashes(stripslashes($val))."' \n AND ";
  83.         }
  84.     }
  85.     
  86.     $sql substr($sql,0,-4);
  87.     
  88.     $sql.= ($db1['dbtype']=='mysql'" LIMIT 1" "";
  89.     
  90.     rpc_debug($sql);
  91.     
  92.     return $sql;
  93. }
  94.  
  95.  
  96. /**
  97.  * Funzione di inserimento nuovo record.
  98.  * Restituisce l'SQL per l'inserimento.
  99.  *
  100.  * @param array $_dati 
  101.  * @param string $tabella 
  102.  * @return string SQL
  103.  */
  104. function rpc_query_insert($_dati,$tabella){
  105.     
  106.     $campi="";
  107.     
  108.     $valori="";
  109.     
  110.     foreach ($_dati as $k=>$val){
  111.         
  112.         $campi.="$k,";
  113.         
  114.         //imposto gli eventuali hidden
  115.         if(variabili_campi($val)!=false$val variabili_campi($val);
  116.         
  117.         $val=urldecode($val);
  118.         
  119.         $valori.="'".addslashes(stripslashes($val))."',";
  120.     }
  121.     
  122.     $campi substr($campi,0,-1);
  123.     $valori substr($valori,0,-1);
  124.     
  125.     $sql "INSERT INTO $tabella ($campiVALUES ($valori)";
  126.     
  127.     rpc_debug($sql);
  128.     
  129.     return $sql;
  130. }
  131.  
  132.  
  133.  
  134. /**
  135.  * Funzione di preparazione query di cancellazione record mediante la maschera di VFront.
  136.  * La funzione è richimata via chiamata esterna Javascript e restituisce il codice SQL.
  137.  *
  138.  * @param array $_pk 
  139.  * @param string $tabella 
  140.  * @return string SQL
  141.  */
  142. function rpc_query_delete($_pk,$tabella){
  143.     
  144.     global $db1;
  145.     
  146.     $campi="";
  147.     
  148.     $valori="";
  149.     
  150.     foreach ($_pk as $k=>$val){
  151.         
  152.         $condizione.=" $k='".addslashes(stripslashes(utf8_decode($val)))."' AND";
  153.     }
  154.     
  155.     $condizione=substr($condizione,0,-3);
  156.     
  157.     $sql "DELETE FROM $tabella WHERE $condizione";
  158.     
  159.     if($db1['dbtype']=='mysql'$sql.=" LIMIT 1";
  160.     
  161.     rpc_debug($sql);
  162.     
  163.     return $sql;
  164. }
  165.  
  166. /**
  167.  * Ricerca mediante la maschera di VFront
  168.  * La funzione è richimata via chiamata esterna Javascript
  169.  * e restituisce gli ID dei record trovati
  170.  *
  171.  * @param array $_dati 
  172.  * @param string $tabella 
  173.  * @return array 
  174.  */
  175. function rpc_query_search($_dati,$tabella){
  176.     
  177.     global $link,$db1;
  178.     
  179.     if(count($_dati)==0){
  180.         return null;
  181.     }
  182.     
  183.     
  184.     $orderby prendi_orderby($tabella,$_SESSION['gid']);
  185.     
  186.     $condizione='';
  187.     
  188.     foreach ($_dati as $k=>$val){
  189.         
  190.         $val=trim($val);
  191.         
  192.         if(strlen($val)>0){
  193.             
  194.             // sperimentale... uso degli asterischi
  195.             if(ereg('\*',$val)){
  196.                 
  197.                 $val=str_replace("*","%",$val);
  198.                 $condizione.=" $k LIKE '".addslashes(stripslashes($val))."' AND";
  199.             }
  200.             else{
  201.                 
  202.                 $condizione.=" $k='".addslashes(stripslashes($val))."' AND";
  203.             }
  204.         }            
  205.     }
  206.     
  207.     $condizione=substr($condizione,0,-3);
  208.     
  209.     // PRENDI LA CHIAVE PRIMARIA DELLA TABELLA
  210.     
  211.     $campoPK prendi_PK($tabella);
  212.     
  213.     
  214.     $sql "SELECT $campoPK FROM $tabella WHERE $condizione ORDER BY $orderby$campoPK ";
  215.     
  216.     $query vmsql_query($sql,$link);
  217.     
  218.     $n_record vmsql_num_rows($query);
  219.     
  220.     list($IDsvmsql_fetch_row_all($query,true);
  221.     
  222.     rpc_debug($sql);
  223.     
  224.     return $IDs;
  225.     
  226. }
  227.  
  228.  
  229.  
  230. /**
  231.  * Funzione RPC per la duplicazione di un record
  232.  *
  233.  * @param array $_pk 
  234.  * @param string $tabella 
  235.  * @return mixed 
  236.  */
  237. function rpc_query_insert_duplicato($_pk,$tabella="",$oid_sub="",$duplica_allegati=0,$duplica_link=0){
  238.     
  239.     global $link,$db1;
  240.     
  241.     // prendi i campi
  242.     list($info_tabella)=prendi_colonne_frontend($tabella,'column_name',false);
  243.     
  244.     list($campo_id$val_ideach($_pk);
  245.     
  246.     
  247.     for($i=0;$i<count($info_tabella);$i++){
  248.         if($info_tabella[$i]!=$campo_id)  $campi[]=$info_tabella[$i];
  249.     }
  250.     
  251.     if(count($info_tabella)>count($campi)){
  252.  
  253.         // test campo numerico
  254.         if(!campo_is_numeric($tabella,$campo_id)){
  255.             
  256.             $val_id="'".addslashes(stripslashes($val_id))."'";
  257.         }
  258.         
  259.         
  260.         
  261.         // ... vai avanti
  262.         $sql="INSERT INTO $tabella (".implode(",",$campi).") 
  263.             (SELECT ".implode(",",$campi)." FROM $tabella WHERE ".$campo_id."=".$val_id.")";
  264.         
  265.         rpc_debug($sql);
  266.         
  267.         $test=vmsql_try($sql,$link,false);
  268.         
  269.         $insert_id = (int) vmsql_insert_id($link,$tabella,$campo_id);
  270.         
  271.         
  272.         // TODO: duplicazione dei dati delle sottomaschere
  273.         
  274.         if($insert_id>&& strlen(trim($oid_sub))>0){
  275.             
  276.             $duplicazione_sub_test=array();
  277.             
  278.             // sottomaschere da duplicare:
  279.             $oid_sub=str_replace("_""," ,substr($oid_sub,0,-1));
  280.             
  281.             // prendi le info sottomaschere
  282.             $sql_sub="SELECT * FROM {$db1['frontend']}.registro_submask WHERE id_submask in ($oid_sub)";
  283.             
  284.             $q_sub vmsql_query($sql_sub,$link);
  285.             
  286.             while($RS_sub=vmsql_fetch_assoc($q_sub)){
  287.                 
  288.                 // SQL per i campi NON auto_increment da prendere
  289.                 $sql_campi="SELECT sc.column_name 
  290.                             FROM {$db1['frontend']}.registro_submask_col AS sc
  291.                                          WHERE id_submask=".$RS_sub['id_submask']." AND sc.extra!='auto_increment'";
  292.                 
  293.                 $q_campi_sub=vmsql_query($sql_campi,$link);
  294.                 
  295.                 list($lista_campi)=vmsql_fetch_row_all($q_campi_sub,true);
  296.                 
  297.                 $duplicazione_sub_test[duplica_record_sottomaschera($RS_sub['nome_tabella'],$lista_campi,$RS_sub['campo_fk_sub'],$val_id,$insert_id);
  298.             }
  299.             
  300.             
  301.             
  302.             rpc_debug($sql_sub);
  303.             
  304.         }
  305.         
  306.         
  307.         // DUPLICAZIONE DEGLI ALLEGATI
  308.         if($duplica_allegati){
  309.             
  310.             $test_allegati=duplica_allegati($tabella,$val_id,$insert_id);
  311.         }
  312.         
  313.         
  314.         
  315.         // DUPLICAZIONE DEi LINK
  316.         if($duplica_link){
  317.             
  318.             $test_link=duplica_link($tabella,$val_id,$insert_id);
  319.         }
  320.         
  321.         
  322.         
  323.         return $test."|".$insert_id;
  324.     }
  325.     
  326.     // altrimenti...
  327.     
  328.     return -1;
  329. }
  330.  
  331.  
  332.  
  333. /**
  334.  * Funzione di duplicazione record
  335.  *
  336.  * @param string $tabella_sub 
  337.  * @param array $elenco_campi 
  338.  * @param string $campo_fk 
  339.  * @param string $valore_fk 
  340.  * @param int|string$nuovo_valore 
  341.  * @return bool 
  342.  */
  343. function duplica_record_sottomaschera($tabella_sub,$elenco_campi,$campo_fk,$valore_fk,$nuovo_valore){
  344.     
  345.     global $link,$db1;
  346.     
  347.     $elenco=array();
  348.     
  349.     for($i=0;$i<count($elenco_campi);$i++){
  350.         
  351.         if($elenco_campi[$i!= $campo_fk{
  352.             $elenco[]=$elenco_campi[$i];
  353.         }
  354.     }
  355.     
  356.     $sql="INSERT INTO ".$tabella_sub" ($campo_fk".implode(",",$elenco)."
  357.     (SELECT '$nuovo_valore', ".implode("," $elenco)." FROM $tabella_sub WHERE $campo_fk='$valore_fk') ";
  358.     
  359.     rpc_debug($sql);
  360.     $test=vmsql_try($sql,$link,false);
  361.     
  362.     return $test;
  363. }
  364.  
  365.  
  366.  
  367. /**
  368.  * Funzione di duplicazione (su richiesta) degli allegati collegati ad un record.
  369.  * Duplica i record informativi su DB e fa una copia fisica dei file
  370.  *
  371.  * @param string $tabella 
  372.  * @param int $id_old 
  373.  * @param int $id_new 
  374.  * @return int 
  375.  */
  376. function duplica_allegati($tabella,$id_old,$id_new){
  377.     
  378.     global $link,$db1;
  379.     
  380.     $matrice_att=prendi_allegati($tabella,$id_old);
  381.     
  382.     $ok=false;
  383.     
  384.     if(count($matrice_att)>0){
  385.         
  386.         $ok=0;
  387.         
  388.         // copia i file 
  389.         for($i=0;$i<count($matrice_att);$i++){
  390.             
  391.             $q0=vmsql_query("BEGIN",$link);
  392.             
  393.             // copia via SQL
  394.             $q=vmsql_query("INSERT INTO "._TABELLA_ALLEGATO." (tipoentitacodiceentitaautorealllastdatanomefileall)
  395.                             VALUES ('$tabella',
  396.                             $id_new
  397.                             '".addslashes(stripslashes($_SESSION['user']['nome']." ".$_SESSION['user']['cognome']))."', 
  398.                             '".date("Y-m-d H:i:s")."', '".$matrice_att[$i]['nomefileall']."')"
  399.                             ,$link);
  400.                             
  401.             // se ha inserito il record
  402.             if(vmsql_affected_rows($link,$q)==1){
  403.                 
  404.                 $id_new_attach=vmsql_insert_id($link,_TABELLA_ALLEGATO,'codiceallegato');
  405.                 
  406.                 // copia il file
  407.                 if(copy(_PATH_ATTACHMENT."/".$matrice_att[$i]['codiceallegato'].".dat",_PATH_ATTACHMENT."/".$id_new_attach.".dat")){
  408.                     $q2=vmsql_query("COMMIT",$link);
  409.                     $ok++;
  410.                 }
  411.                 else{
  412.                     $q2=vmsql_query("ROLLBACK",$link);
  413.                 }
  414.                 
  415.             }
  416.         }
  417.     }
  418.     
  419.     if($ok===false){
  420.         
  421.         return 0;
  422.     }
  423.     else if($ok!=count($matrice_att)){
  424.         return -1;
  425.     }
  426.     else {
  427.         return $ok;
  428.     }
  429.     
  430. }
  431.  
  432.  
  433. /**
  434.  * Funzione di duplicazione (su richiesta) dei link collegati ad un record.
  435.  *
  436.  * @param string $tabella 
  437.  * @param int $id_old 
  438.  * @param int $id_new 
  439.  * @return int 
  440.  */
  441. function duplica_link($tabella,$id_old,$id_new){
  442.     
  443.     global $link,$db1;
  444.     
  445.     $matrice_link=prendi_link($tabella,$id_old);
  446.     
  447.     $ok=false;
  448.     
  449.     if(count($matrice_link)>0){
  450.         
  451.         $ok=0;
  452.         
  453.         // copia i file 
  454.         for($i=0;$i<count($matrice_link);$i++){
  455.             
  456.             // copia via SQL
  457.             $q=vmsql_query("INSERT INTO "._TABELLA_LINK." (tipoentitacodiceentitalinklastdatadescrizione)
  458.                             VALUES ('$tabella',
  459.                             $id_new
  460.                             '".addslashes(stripslashes($matrice_link[$i]['link']))."', 
  461.                             '".date("Y-m-d H:i:s")."', 
  462.                             '".$matrice_link[$i]['descrizione']."')"
  463.                             ,$link);
  464.                             
  465.             // se ha inserito il record
  466.             if(vmsql_affected_rows($link,$q)==1$ok++;
  467.         }
  468.     }
  469.     
  470.     if($ok===false){
  471.         
  472.         return 0;
  473.     }
  474.     else if($ok!=count($matrice_link)){
  475.         return -1;
  476.     }
  477.     else {
  478.         return $ok;
  479.     }
  480. }
  481.  
  482.  
  483.  
  484.  
  485. ###############################################################################################
  486. #
  487. #    FUNZIONI RPC per le sottomaschere
  488. #
  489. ###############################################################################################
  490.  
  491.  
  492. /**
  493.  * Funzione di modifica dei record delle sottomaschere.
  494.  * Restituisce codice SQL
  495.  *
  496.  * @param array $_dati 
  497.  * @param string $_str_pk_indipendente 
  498.  * @param string $pk_dipendente 
  499.  * @param string $tabella 
  500.  * @param string $hash_campo 
  501.  * @return string SQL
  502.  */
  503. function rpc_sub_query_update($_dati,$_str_pk_indipendente,$pk_dipendente,$tabella="",$hash_campo){
  504.     
  505.     global $link$db1;
  506.     
  507.     
  508.     $sql_out=array();
  509.     
  510.     if(!is_array($_dati)){
  511.         
  512.         return null;
  513.     }
  514.     
  515.     
  516.     $sql_auto="SELECT c.column_name 
  517.                          FROM {$db1['frontend']}.registro_col c , {$db1['frontend']}.registro_tab t
  518.                          WHERE c.extra='auto_increment'
  519.                          AND t.gid=0
  520.                          AND t.id_table=c.id_table
  521.                          AND t.table_name='$tabella'";
  522.     
  523.     // Cerca eventuali campi Autoincrement:
  524.     $q_auto=vmsql_query($sql_auto,$link);
  525.     
  526.     if(vmsql_num_rows($q_auto)>0){
  527.         list($campo_auto_incvmsql_fetch_row($q_auto);
  528.     }
  529.     else{
  530.         $campo_auto_inc='';
  531.     }
  532.     
  533.     
  534.     
  535.     foreach($_dati as $k=>$arval){
  536.         
  537.     
  538.         $buffer_string="";
  539.         $campi='';
  540.         $valori='';
  541.         $campo='';
  542.         $valore='';
  543.         $campo_pk_indip="";
  544.         $valore_pk_indip="";
  545.         
  546.         
  547.         
  548.         
  549.             
  550.         $hash_campo_obj=unserialize(base64_decode($hash_campo[$k]));
  551.         
  552.         
  553.         // NUOVO DATO
  554.         if(!$hash_campo[$k]){
  555.             
  556.             
  557.             foreach($arval as $campo=>$valore){
  558.                 
  559.                 // non mettere i campi auto_increment se ci dovessero essere
  560.                 if($campo!=$campo_auto_inc){
  561.                     
  562.                     $campi.=$campo.",";
  563.                     
  564.                     if($db1['dbtype']=='postgres' && campo_is_numeric($tabella,$campo)){
  565.                         $valori.= addslashes(stripslashes($valore)).",";
  566.                     }
  567.                     else{
  568.                         $valori.="'".addslashes(stripslashes($valore))."',";
  569.                     }
  570.                 }
  571.             }
  572.             
  573.             
  574.             list($campo_pk_indip,$valore_pk_indipexplode("=",$_str_pk_indipendente);
  575.  
  576.             // accodo i dati della pk indipendente se non è auto_increment
  577.             if($campo_pk_indip!=$campo_auto_inc){
  578.                 $campi.=$campo_pk_indip;
  579.                 $valori.=$valore_pk_indip;
  580.             }
  581.             else{
  582.                 $campi=substr($campi,0,-1);
  583.                 $valori=substr($valori,0,-1);
  584.             }
  585.             
  586.             $buffer_string="INSERT INTO $tabella ($campiVALUES ($valori)";
  587.             
  588.         }    //-- fine INSERT
  589.         
  590.         
  591.         
  592.         // DATO DA MODIFICARE
  593.         else{
  594.             
  595.                 if(is_array($hash_campo&& count($hash_campo_obj)>0){
  596.                 
  597.                     $WHERE='WHERE 1=1 ';
  598.                     
  599.                     foreach($hash_campo_obj as $campo_h=>$valore_h){
  600.                         
  601.                         if($valore_h!=''){
  602.                             if($db1['dbtype']=='postgres' && campo_is_numeric($tabella,$campo_h)){
  603.                                 $WHERE.=" AND $campo_h=".addslashes(stripslashes($valore_h));
  604.                             }
  605.                             else{
  606.                                 $WHERE.=" AND $campo_h='".addslashes(stripslashes($valore_h))."'";
  607.                             }
  608.                         
  609.                         }
  610.                         else{
  611.                             
  612.                             $WHERE.=" AND ($campo_h IS NULL)";
  613.                         }
  614.                     }
  615.                 }
  616.                 
  617.                 // PREVENGO LA CREAZIONE DI UN UPDATE SENZA CONDIZIONI
  618.                 else return '';
  619.                 
  620.                 
  621.                 $buffer_string="UPDATE $tabella SET ";
  622.                 
  623.                 foreach($arval as $campo=>$valore){
  624.                     
  625.                     if($db1['dbtype']=='postgres' && campo_is_numeric($tabella,$campo)){
  626.                         $buffer_string.=" $campo=".addslashes(stripslashes($valore)).",";
  627.                     }
  628.                     else{
  629.                         $buffer_string.=" $campo='".addslashes(stripslashes($valore))."',";
  630.                     }
  631.                 }
  632.                 
  633.                 $buffer_string=substr($buffer_string,0,-1);
  634.                 
  635.                 if(!isset($WHERE|| $WHERE=='WHERE 1=1 '){
  636.                     return '';
  637.                 }
  638.                 
  639.                 $buffer_string.=" $WHERE ";
  640.             
  641.             
  642.         //-- fine UPDATE
  643.         
  644.         
  645.         $sql_out[]=$buffer_string;
  646.         
  647.         
  648.     
  649.     // -- fine ciclo
  650.     
  651.     
  652. //    print_r($sql_out);
  653.     
  654.     return $sql_out;
  655.     
  656. }
  657.  
  658.  
  659. /**
  660.  * Funzione per la cancellazione di un record in sottomaschera.
  661.  * Restituisce il codice SQL
  662.  *
  663.  * @param string $campo_pk_dip 
  664.  * @param string $valore_pk_dip 
  665.  * @param string $campo_pk_indip 
  666.  * @param string $valore_pk_indip 
  667.  * @param string $tabella 
  668.  * @param string $hash 
  669.  * @return string SQL
  670.  */
  671. function rpc_sub_query_delete($campo_pk_dip,$valore_pk_dip,$campo_pk_indip,$valore_pk_indip,$tabella,$hash){
  672.     
  673.     for($i=0;$i<count($hash);$i++){
  674.         
  675.         $hash_campo_obj=unserialize(base64_decode($hash[$i]));
  676.         
  677.         $WHERE='WHERE 1=1 ';
  678.         
  679.         if(is_array($hash_campo_obj)){
  680.         
  681.             foreach($hash_campo_obj as $campo_h=>$valore_h){
  682.                 
  683.                 if($valore_h!=''){
  684.                 
  685.                     $WHERE.=" AND $campo_h='".addslashes(stripslashes($valore_h))."'";
  686.                 
  687.                 }
  688.                 else{
  689.                     
  690.                     $WHERE.=" AND ($campo_h='".addslashes(stripslashes($valore_h))."OR $campo_h IS NULL)";
  691.                 }
  692.             }
  693.         }
  694.         
  695.         
  696.     
  697.         $sql_out[]="DELETE FROM $tabella $WHERE LIMIT 1";
  698.     }
  699.     
  700.     return $sql_out;
  701.     
  702. }
  703.  
  704.  
  705.  
  706. /**
  707.  * Funzione di cancellazione di un allegato di un record.
  708.  *
  709.  * @param string $tabella 
  710.  * @param int $id 
  711.  * @return bool 
  712.  */
  713. function rpc_delete_attach($tabella,$id){
  714.     
  715.     
  716.     global $link,$db1;
  717.     
  718.     $sql_att="SELECT codiceallegato FROM "._TABELLA_ALLEGATO." WHERE codiceentita='$idAND tipoentita='$tabella'";
  719.     
  720.     $q_att vmsql_query($sql_att,$link);
  721.     
  722.     list($array_codice_allegati)=vmsql_fetch_row_all($q_att,true);
  723.     
  724.     for($i=0;$i<count($array_codice_allegati);$i++){
  725.         
  726.         // elimino dal filesystem
  727.         $test_del_fs=@unlink(_PATH_ATTACHMENT."/".$array_codice_allegati[$i].".dat");
  728.         
  729.         // elimino dal db
  730.         $sql_del="DELETE FROM "._TABELLA_ALLEGATO." WHERE codiceallegato=".$array_codice_allegati[$i]." LIMIT 1";
  731. //        rpc_debug($sql_del);
  732.         $test_del=vmsql_query($sql_del,$link);
  733.         
  734.         
  735.     }
  736.     
  737.      return ($test_del_fs && $test_deltrue:false;
  738. }
  739.  
  740.  
  741.  
  742. /**
  743.  * Funzione di cancellazione di un link di una scheda.
  744.  *
  745.  * @param string $tabella 
  746.  * @param int $id 
  747.  * @return bool 
  748.  */
  749. function rpc_delete_link($tabella,$id){
  750.     
  751.     global $link,$db1;
  752.     
  753.     $sql_link "SELECT codicelink FROM "._TABELLA_LINK." WHERE codiceentita='$idAND tipoentita='$tabella'";
  754.     
  755.     
  756.     
  757.     $q_link vmsql_query($sql_link,$link);
  758.     
  759.     list($array_codice_link)=vmsql_fetch_row_all($q_link,true);
  760.     
  761.     for($i=0;$i<count($array_codice_link);$i++){
  762.         
  763.         // elimino dal db
  764.         $sql_del="DELETE FROM "._TABELLA_LINK." WHERE codicelink=".$array_codice_link[$i]." LIMIT 1";
  765. //        rpc_debug($sql_del);
  766.         $test_del=vmsql_query($sql_del,$link);
  767.         
  768.     }
  769.     
  770.      return $test_del;
  771.     
  772. }
  773.  
  774.  
  775.  
  776. ?>

Documentation generated on Sat, 22 Sep 2007 11:50:21 +0200 by phpDocumentor 1.4.0a2