Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/04/2013, 10:02
ambichol
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 2 meses
Puntos: 5
Respuesta: Intermitencia PHP - SQL

claro...lo que sucede es que trabajo con el sql 2008 y hay algunas funciones que son necesarias para el trabajo que realizo(Pivots para ser mas preciso)y al borrar las tablas el SP que ejecuto nuevamente las vuelve a crear....

pero bueno les comparto el codigo:

Código PHP:
Ver original
  1. <?php
  2. include ('../Conexion/cnx_php.php');
  3. include('fusion/cnx.php');
  4. include('fusion/DWFChart.inc.php');
  5. include('fusion/fc_data.php');
  6.  
  7. $gestion='GES03';
  8. $sql ="
  9. DROP TABLE A
  10. SELECT t02.DES_FECHA AS FECHA,COD_GES,D1,D2
  11. INTO A
  12. FROM TAB_PH3_ANUAL_01 t01
  13. INNER JOIN TAB_MES t02
  14. ON t01.FECHA=t02.COD_FECHA
  15. WHERE COD_GES='$gestion'
  16.  
  17. DROP TABLE B
  18. SELECT *
  19. INTO B
  20. FROM TAB_PH3_ANUAL_02
  21. WHERE COD_GES='$gestion' ";
  22.  
  23. $sql = mssql_query($sql) or die(mssql_error());
  24. ?>
  25. <!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  27. <head>
  28. <script language="JavaScript">
  29. <!--
  30. function final(){
  31. parent.location="#final"
  32. }
  33. //-->
  34. </script>
  35.  
  36.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  37.     <title>::</title>
  38.     <script type="text/javascript" src="fusion/FusionCharts.js"></script>
  39.     <link href="estilo.css" rel="stylesheet" type="text/css" />
  40.    
  41.     <!--Inicio Extjs-->
  42.     <link rel="stylesheet" type="text/css" href="../../ext-3.4.0/resources/css/ext-all.css" />
  43.     <script type="text/javascript" src="../../ext-3.4.0/adapter/ext/ext-base-debug.js"></script>  
  44.     <script type="text/javascript" src="../../ext-3.4.0/ext-all-debug.js"></script>
  45.    
  46.     <!-- Otros Extjs--->
  47.     <link rel="stylesheet" type="text/css" href="../../ext-3.4.0/examples/ux/gridfilters/css/GridFilters.css" />
  48.     <link rel="stylesheet" type="text/css" href="../../ext-3.4.0/examples/ux/gridfilters/css/RangeMenu.css" />
  49.     <link rel="stylesheet" type="text/css" href="../../ext-3.4.0/examples/ux/css/LockingGridView.css" />
  50.    
  51.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/menu/RangeMenu.js"></script>
  52.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/menu/ListMenu.js"></script>
  53.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/GridFilters.js"></script>
  54.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/Filter.js"></script>
  55.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/StringFilter.js"></script>
  56.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/DateFilter.js"></script>
  57.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/ListFilter.js"></script>
  58.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/NumericFilter.js"></script>
  59.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/gridfilters/filter/BooleanFilter.js"></script>
  60.     <script type="text/javascript" src="../../ext-3.4.0/examples/ux/LockingGridView.js"></script>
  61.     <script type="text/javascript" src="currency.js"></script>
  62.     <script type="text/javascript" src="02.lock-grid.js"></script>
  63.     <!--Fin Extjs-->
  64. </head>
  65. <form name="form1" method="post" action="">
  66. <!--Extjs-->
  67. <table width= 1033 border=0>
  68.  <tr>
  69.     <td class="titulo">
  70.         Gestión de Proveedores
  71.     <br>
  72.     </td>
  73.  
  74.  </tr>
  75.  <tr>
  76.  <td>
  77.         <table border=0 width=450  style="margin-left:30px">
  78.         <tr>
  79.             <td class="Tema2">
  80.             <br>
  81.             Elija una Gestión:
  82.             </td>
  83.             <td>
  84.             <br>
  85.                 <select name="cb1">
  86.                     <option value=''>--</option>
  87.                 <?php
  88.                     //include "../Conexion/cnx_php.php";
  89.                     $SQL = "SELECT COD_GES,DES_GES FROM TAB_GESTION";
  90.                     $resultado=mssql_query($SQL);
  91.                     while($row = mssql_fetch_row($resultado)) {
  92.  
  93.                     echo "<option value='".$row['0']."'>".$row['1']."</option>";
  94.  
  95.                     }
  96.                
  97.                 ?>
  98.                 </select>
  99.             </td>
  100.             <td>
  101.             <br>
  102.             <input type="submit" name='b1' value="Actualizar">
  103.             </td>
  104.         </tr>
  105.         </table>
  106.  </td>
  107.  </tr>
  108.  <tr>
  109.     <td colspan=2>
  110.         <?php
  111.             if(isset($_REQUEST['cb1'])){
  112.  
  113.                 $gestion= $_REQUEST['cb1'];
  114.  
  115.                 if ($gestion ==""){
  116.         ?>
  117.             <script>
  118.                     alert ("¡Debe seleccionar una Gestión! ");
  119.                     window.location = '#';
  120.             </script>
  121.         <?php
  122.  
  123.             }
  124.  
  125.  
  126. $sql ="
  127. DROP TABLE A
  128. SELECT t02.DES_FECHA AS FECHA,COD_GES,D1,D2
  129. INTO A
  130. FROM TAB_PH3_ANUAL_01 t01
  131. INNER JOIN TAB_MES t02
  132. ON t01.FECHA=t02.COD_FECHA
  133. WHERE COD_GES='$gestion'
  134.  
  135. DROP TABLE B
  136. SELECT *
  137. INTO B
  138. FROM TAB_PH3_ANUAL_02
  139. WHERE COD_GES='$gestion' ";
  140.  
  141. $sql = mssql_query($sql) or die(mssql_error());
  142.  
  143.             }
  144.         ?>
  145.     </td>
  146. </tr>
  147.  <tr>
  148.     <td class="Tema2"><center><b><h1>
  149.     GESTIÓN
  150.     <?php
  151.  
  152.                     $SQL = "SELECT DES_GES FROM TAB_GESTION WHERE COD_GES='$gestion'";
  153.                     $resultado=mssql_query($SQL);
  154.                     while($row = mssql_fetch_row($resultado)) {  
  155.                     echo $row['0'];
  156.                     }
  157.     ?>
  158.     </h1></b></center>
  159.     </td>
  160. </tr>
  161. </table>
  162. <!--Fusion Chart-->
  163. <?php
  164.     //require_once('fusion/cnx.php');
  165.     //include('fusion/DWFChart.inc.php');
  166.     //fusionchart data include
  167.     //include('fusion/fc_data.php');
  168.  
  169. if (!function_exists("GetSQLValueString")) {
  170. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  171. {
  172.   $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  173.   $theValue = function_exists("mssql_real_escape_string") ? mssql_real_escape_string($theValue) : mssql_escape_string($theValue);
  174.  
  175.   switch ($theType) {
  176.     case "text":
  177.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  178.       break;    
  179.     case "long":
  180.     case "int":
  181.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  182.       break;
  183.     case "double":
  184.       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  185.       break;
  186.     case "date":
  187.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  188.       break;
  189.     case "defined":
  190.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  191.       break;
  192.   }
  193.   return $theValue;
  194. }
  195. }
  196. // conexion data
  197. mssql_select_db($database, $inicio);
  198. $query_rs =
  199. "SELECT * FROM A";
  200. $rs = mssql_query($query_rs, $inicio) or die(mssql_error());
  201. $row_rs= mssql_fetch_assoc($rs);
  202. $totalRows_rs = mssql_num_rows($rs);
  203.  
  204. // fusionchart dynamic filter data 00FFFF
  205. $dFC = new DWFChart("FusionChart", "MSColumn2D", "fusion/", 1000, 330, "", "", "", "", "", "");
  206. $dFC->setVersion("1.1.1");
  207. $dFC->setConfigXML($dataXML);
  208. $dFC->setCategory($rs, "FECHA", "", "");
  209. $dFC->addSeries($rs, "D1", "", "color='FFCC67' seriesName='Gasto' renderAs='Area' parentYAxis='P'", "default", "");
  210. $dFC->addSeries($rs,  "D2", "", "color='00527A' seriesName='Presupuesto' renderAs='Line' parentYAxis='P'", "default", "");
  211. $dFC->setOrdering('None', 'asc');
  212. $dFC->prepareData();
  213.  
  214. ?>
  215.  <table width="951" border="0" cellpadding="0" cellspacing="0" bgcolor="" style="margin-left:30px">
  216.  <tr>
  217.     <td height="20" colspan="3" valign="top" class="Tema">Gasto Vs Presupuesto - Anual - Gestión    
  218.                 <?php
  219.                     $SQL = "SELECT DES_GES FROM TAB_GESTION WHERE COD_GES='$gestion'";
  220.                     $resultado=mssql_query($SQL);
  221.                     while($row = mssql_fetch_row($resultado)) {  
  222.                         echo $row['0'];
  223.                     }
  224.                 ?>
  225.                 - 2013
  226.     </td>
  227.  </tr>
  228.  <tr>
  229.     <td height="280" colspan="3" valign="top">&nbsp;      
  230.         <?php
  231.             renderFusionChart($dFC,"","");
  232.         ?>
  233.     </td>
  234.  </tr>
  235.   <tr>
  236.     <td>
  237.             <div id="02.grid"></div>
  238.             <br><br>
  239.     </td>
  240.  </tr>
  241.   </table>
  242.   </form>
  243. <!--  <form name="form2" method="post" action="">
  244.   <table  width="910" style="margin-left:30px" border=0>
  245.   <tr>
  246.     <td align="right"><a href="#top"><img src="botonSubir.gif"></a>
  247.     </td>
  248.  </tr>
  249.  </table>
  250.     <a name="final"></a>
  251.   </form>-->
  252. </body>
  253. </html>