Foros del Web » Programando para Internet » PHP »

PHP OO Como imprimo el conteido de un query y porque me manda este error???

Estas en el tema de Como imprimo el conteido de un query y porque me manda este error??? en el foro de PHP en Foros del Web. Hola Ayudenme a analizar este código, por fis!!! Tengo un problema con la impresión del contenido de un query q es llamado por un archivo ...
  #1 (permalink)  
Antiguo 26/11/2010, 08:53
 
Fecha de Ingreso: febrero-2010
Mensajes: 57
Antigüedad: 14 años, 2 meses
Puntos: 1
Como imprimo el conteido de un query y porque me manda este error???

Hola Ayudenme a analizar este código, por fis!!!
Tengo un problema con la impresión del contenido de un query q es llamado por un archivo php(o pueden ser varios, no estoy segura), pues no encuentro las variables q tengo q llamar y todas las q he impreso, salen como Object o Array.
Dicho query se encuentra en el archivo var_reporter_mssql.xml y es lo siguiente:

Código xml:
Ver original
  1. <?xml version="1.0" ?>
  2. <SQLLIST database="MSSQL" module="VAR_REPORTER">
  3. <SQL ID="GET_DETAIL_DN_ALL"
  4.     QUERY=" SELECT app_id as APP_ID, convert(varchar(40),call_id) as CALL_ID, convert(char(19),tz_date,120) as TZ_DATE, ani as ANI ,dnis as DNIS,
  5.             ivr_duration as IVR_DURATION, case end_action when ''01'' then ''Call End'' when ''02'' then ''Transfer'' else ''Abandon'' end as END_ACTION,
  6.             case ivr_result when ''S'' then ''Success'' when ''F'' then ''Failure'' else ''Unknown'' end as  IVR_RESULT ,
  7.             ivr_reason as IVR_REASON
  8.             FROM app_calls  WITH ( INDEX ( IX_call_ani ) )  
  9.             WHERE tz_date &gt;= CONVERT(DATETIME, :VAR_UTC_DT_START ,120 ) and tz_date &lt; CONVERT(DATETIME, :VAR_UTC_DT_END ,120 ) and ani in ( :VAR_DN_1 , :VAR_DN_2 , :VAR_DN_3 , :VAR_DN_4 , :VAR_DN_5 , :VAR_DN_6 , :VAR_DN_7 , :VAR_DN_8 , :VAR_DN_9 , :VAR_DN_10  ) ORDER BY ani, tz_date desc "/>
  10. <SQL ID="GET_DETAIL_DN_APP"
  11.     QUERY=" SELECT app_id as APP_ID, convert(varchar(40),call_id) as CALL_ID, convert(char(19),tz_date,120) as TZ_DATE, ani as ANI ,dnis as DNIS, ivr_duration as IVR_DURATION, case end_action when ''01'' then ''Call End'' when ''02'' then ''Transfer'' else ''Abandon'' end as END_ACTION, case ivr_result when ''S'' then ''Success'' when ''F'' then ''Failure'' else ''Unknown'' end as  IVR_RESULT , ivr_reason as IVR_REASON FROM app_calls  WITH ( INDEX ( IX_call_ani ) )  WHERE tz_date &gt;= CONVERT(DATETIME, :VAR_UTC_DT_START ,120 ) and tz_date &lt; CONVERT(DATETIME, :VAR_UTC_DT_END ,120 ) and app_id = :VAR_APP_ID   and ani in ( :VAR_DN_1 , :VAR_DN_2 , :VAR_DN_3 , :VAR_DN_4 , :VAR_DN_5 , :VAR_DN_6 , :VAR_DN_7 , :VAR_DN_8 , :VAR_DN_9 , :VAR_DN_10  ) ORDER BY ani , tz_date desc " /> </SQLLIST>

Este archivo es llamado por el archivo vwm_sql_xml.php mediante el siguiente código en PHP:
Código php:
Ver original
  1. function load_xml()
  2. { ...
  3.      $xmlFilePath = $CN_ROOT . $SEP . "php" . $SEP . "xml" .$SEP . strtolower($MODULE_ID) . "_" . strtolower($VWM_INI ["DBTYPE"]) . ".xml"; /*Asignación de la variable con el nombre de archivo var_reporter_mssql.xml */
  4. ....
  5. //Load the XML file into a String
  6.       if ( ! ($tempArray = file($xmlFilePath) ) )
  7.              {  $VWM_LOGGER->Log("Cannot Read XML File " . " - " . $xmlFilePath, "ERROR", "1103");
  8.     return false;
  9.     }
  10. //implode result
  11. $xmlStr = implode($tempArray,"");
  12. //Load XML into a DOM object
  13. if ( ! ($this->sqlDOM = @xmldoc($xmlStr) ) )
  14. {
  15.  ....
  16. }
  17.    $this->xmlFile = $xmlFilePath;
  18.         return true;
  19.     }
  20.  
  21. function get_sql($sql_id) /*función para obtener el ID del query SQL del archivo var_reporter_mssql.xml indicado arriba*/
  22.     {
  23.          global $VWM_LOGGER;
  24.          $retSQL = "";
  25.  ....

En el código anterior hay una función q obtiene el ID del SQL q puede ser "GET_DETAIL_DN_APP" o "GET_DETAIL_DN_ALL" segun el archivo xml y lo guarda en la variable $sql_id.
Si no me equivoco, después de esto se va a presentarlo en la web mediante el archivo var_report_viewer.php con ayuda de entre otros archivos del left_side_menu.php, q es donde se le telcea en el campo de texto cualquier número de 10 digitos.
El código de var_report_viewer.php es:

Código php:
Ver original
  1. if ($_GET["DN1"] != '')
  2. {
  3.     $DN1 = $_GET["DN1"];
  4.     $DN2 = $_GET["DN2"];
  5.     $DN3 = $_GET["DN3"];
  6.     $DN4 = $_GET["DN4"];
  7.     $DN5 = $_GET["DN5"];
  8.     $DN6 = $_GET["DN6"];
  9.     $DN7 = $_GET["DN7"];
  10.     $DN8 = $_GET["DN8"];
  11.     $DN9 = $_GET["DN9"];
  12.     $DN10 = $_GET["DN10"];
  13. }
  14. $printURL = "var_report_viewer.php?" .
  15.             "ReportType=" . $ReportType .
  16.             "&Application=" . $RepApplication .
  17.             "&StartDate=" . $RepStartDate .
  18.             "&StartTime=" . $RepStartTime .
  19.             "&EndDate=" . $RepEndDate .
  20.             "&EndTime=" . $RepEndTime .
  21.             "&RepInterval=" . $RepInterval.
  22.             "&SCF=" . $RepSCF .
  23.             "&Print=Y";
  24. ....
  25. //Handle information
  26. //Find application Name
  27.  
  28. if ($RepApplication == "ALL")
  29. {
  30.     $RepContext = "All DNIS Applications";
  31. }
  32. else
  33. {
  34.     $RepContext = get_app_name($RepApplication);
  35. }
  36.  
  37. //Find Reports Name and set Reports File
  38. switch ($ReportType)
  39. {
  40.     case "DETALLE_LLAMADA"  :   $ReportName = "Listado de llamadas realizadas por Dn";
  41.     $ReportFile = "var_calls_listing.php";
  42.     $sqlID  = "GET_DETAIL_DN";
  43.         break;
  44.     case "SAVEFILE" :   $ReportName = "Save Download File";
  45.     $ReportFile = "var_download_file.php";
  46.     $sqlID      = "GET_DOWNLOAD";
  47.                        
  48.     $dwl_type = $_GET["DwlReportType"];
  49.                         $sqlID .= "_".$dwl_type;
  50. .....                      
  51. //Prepare Dates for SQL. Add 1 day to end date if time is not specified
  52. if ($RepStartTime == -1 and $RepEndTime == -1)
  53. {
  54.     $RepEndDTInt = dateadd("d",1,$RepEndDTInt);
  55. }
  56.  
  57. $sqlStartDate = date("Y-m-d H:i:s", $RepStartDTInt);
  58. $sqlEndDate = date("Y-m-d H:i:s", $RepEndDTInt);
  59. if ($ReportType == "DETALLE_LLAMADA" )
  60. {
  61. $RepStartDTInt = dateadd("m",-1,$RepEndDTInt);
  62. $RepEndDTInt = dateadd("s",-1,$RepEndDTInt);
  63. $sqlEndDate = date("Y-m-d H:i:s", $RepEndDTInt);
  64. $sqlStartDate = date("Y-m-d H:i:s", $RepStartDTInt);
  65. echo "Fecha de inicio: " . $sqlStartDate . "<br>";
  66. echo "Fecha de fin:    " . $sqlEndDate . "<br>";
  67.     if ($RepApplication != "ALL") {
  68.     $sqlID .= "_APP";
  69.     $sql_params = array (   "APP_ID" => $RepApplication ,
  70.     "UTC_DT_START" => $sqlStartDate ,
  71.     "UTC_DT_END" => $sqlEndDate,
  72.     "DN_1" => $DN1,
  73.     "DN_2" => $DN2,
  74.     "DN_3" => $DN3,
  75.     "DN_4" => $DN4,
  76.     "DN_5" => $DN5,
  77.     "DN_6" => $DN6,
  78.     "DN_7" => $DN7,
  79.     "DN_8" => $DN8,
  80.     "DN_9" => $DN9,
  81.     "DN_10" => $DN10                            );
  82.     } else {
  83.     $sqlID .= "_ALL";
  84.     $sql_params = array (
  85.                  "UTC_DT_START" => $sqlStartDate ,
  86.     "UTC_DT_END" => $sqlEndDate,
  87.     "DN_1" => $DN1,
  88.     "DN_2" => $DN2,
  89.     "DN_3" => $DN3,
  90.     "DN_4" => $DN4,
  91.     "DN_5" => $DN5,                         "DN_6" => $DN6,                         "DN_7" => $DN7,                         "DN_8" => $DN8,                         "DN_9" => $DN9,                         "DN_10" => $DN10);
  92.     }
  93. }
  94. elseif ($ReportType == "SCF_ANALYSIS" )
  95. {
  96.     $sql_params = array (   "APP_ID" => $RepApplication ,
  97.                 "SCF_ID" => $RepSCF,
  98.                 "UTC_DT_START" => $sqlStartDate ,
  99.                                                     "UTC_DT_END" => $sqlEndDate);  
  100. }
  101. elseif ($RepApplication != "ALL")
  102. {
  103.     $sqlID .= "_APP";
  104.     $sql_params = array (   "APP_ID" => $RepApplication ,
  105.                             "UTC_DT_START" => $sqlStartDate ,
  106.     "UTC_DT_END" => $sqlEndDate);
  107. }
  108. else
  109. {
  110.     $sqlID .= "_ALL";
  111.     $sql_params = array (   "UTC_DT_START" => $sqlStartDate ,
  112.     "UTC_DT_END" => $sqlEndDate);  
  113. }
  114. ....
  115. $repData = $varSQL->get_array();
  116. ....

Al final siempre q elijo el tipo de aplicación "GET_DETAIL_DN_ALL" o "GET_DETAIL_DN_APP" me aparece el siguiente error en el log:

Código txt:
Ver original
  1. "2010-11-25 18:29:10 : ERROR : 1250 : Cannot find size for variable :VAR_DN_1 found in SQL  SELECT app_id as APP_ID, convert(varchar(40),call_id) as CALL_ID, convert(char(19),tz_date,120) as TZ_DATE, ani as ANI ,dnis as DNIS,    ivr_duration as IVR_DURATION, case end_action when ''01'' then ''Call End'' when ''02'' then ''Transfer'' else ''Abandon'' end as END_ACTION,     case ivr_result when ''S'' then ''Success'' when ''F'' then ''Failure'' else ''Unknown'' end as  IVR_RESULT ,    ivr_reason as IVR_REASON    FROM app_calls  WITH ( INDEX ( IX_call_ani ) )      WHERE tz_date >= CONVERT(DATETIME, :VAR_UTC_DT_START ,120 ) and tz_date < CONVERT(DATETIME, :VAR_UTC_DT_END ,120 )    and ani in ( :VAR_DN_1 , :VAR_DN_2 , :VAR_DN_3 , :VAR_DN_4 , :VAR_DN_5 , :VAR_DN_6 , :VAR_DN_7 , :VAR_DN_8 , :VAR_DN_9 , :VAR_DN_10  )    ORDER BY ani, tz_date desc
  2. 2010-11-25 18:29:10 : ERROR : 1203 : Error Binding variables
  3. 2010-11-25 18:29:10 : ERROR : 1250 : DoSQL: Parsing failed
  4. 2010-11-25 18:29:10 : ERROR : 20201 : ClientIP[192.168.55.29] No se puede obtener informacion para: Listado de llamadas realizadas por Dn"

Este log es presentado mediante el archivo vwm_db_mssql.php, su código es:

Código php:
Ver original
  1. ......
  2. class tlraDBSQL
  3. {
  4. .....
  5.     //Instantiate with a Statement
  6.     function tlraDBSQL($argSQL)
  7.     {
  8. ....        //Create Array of variables and bound them
  9.         if ( ! ($this->create_param_array() ) )
  10.         {
  11.             $VWM_LOGGER->Log("Error Binding variables ",  "ERROR", "1203");
  12.             return false;
  13.         }
  14.         $this->dbBatchSize = $pre_fetch;
  15.         return true;
  16.     }
  17.     function create_param_array()
  18.     {
  19.         global $VWM_LOGGER;
  20.         $tempSQL = $this->dbSQL;
  21.         $curPos = 0;
  22.         $this->dbParamDef = "";
  23.         $this->dbParams = array();
  24.         $data_info = new vwm_data_info();
  25.         while ( ($curPos = strpos($tempSQL,":VAR")) > 0)
  26.         {
  27.             $varEnd = strpos($tempSQL," ",$curPos);
  28.             //Check if variable is at the end
  29.             if ($varEnd <=0) $varEnd = strlen($tempSQL);
  30.             $ParamName = substr($tempSQL, $curPos, $varEnd - $curPos);
  31.             $ParamKey = substr($ParamName,5);
  32.             if ( ! array_key_exists($ParamKey, $this->dbParams) )
  33.             {
  34.             $varSize = $data_info->getsize($ParamKey);                          $varType = $data_info->gettype($ParamKey);
  35.  
  36.                 if ($varSize === -1)
  37.                 {
  38.                 $VWM_LOGGER->Log("Cannot find size for variable " . $ParamName . /*Error que presenta en el log */
  39.                      " found in SQL " .$this->dbSQL, "ERROR", "1250");
  40.      return false;
  41.         }
  42. ......?>

Cualquier comentario es bueno. Muchisimas gracias por su ayuda.
Spider Marsh
  #2 (permalink)  
Antiguo 26/11/2010, 10:45
Avatar de Nano_  
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: Como imprimo el conteido de un query y porque me manda este error???

Saludos

1. Al parecer el error esta en la construcción del xml esta seguro que esta bien generado?
2. Pensaría que te queda mas fácil utilizando la librería simpleXML. Lo has intentado?
__________________
:.:Nano.:: @nano_hard - Retornando al foro

Etiquetas: query
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:33.