Ver Mensaje Individual
  #6 (permalink)  
Antiguo 25/10/2012, 05:19
taboacar
 
Fecha de Ingreso: octubre-2012
Ubicación: Pozuelo de Alarcón
Mensajes: 67
Antigüedad: 11 años, 5 meses
Puntos: 1
Respuesta: Problema al sacar por pantalla una consulta de mas de 99 elementos.

Muchísimas gracias por su respuesta.

Siento mucho no haber puesto el código en Highlight pero soy nuevo en el foro y no se muy bien como va esto.

Acabo de probar su respuesta y sigue dando el mismo resultado.
Analizando bien la función select me doy cuenta que el resultado en la variable $resultado queda exactamente igual que si pongo menos elementos.
El problema que después parece que no reconoce ese resultado puesto que en filter_rows que le entra como argumentos ($rows), es decir el resultado de la función select no lo reconoce y esta vacío. En cambio con menos elementos si que esta lleno.

Le pongo la función filter_rows($rows) y select de la forma correspondiente para que pueda verlo mejor:

Código PHP:
Ver original
  1. public function select($table, $select_fields, $where_values=NULL, $concat=NULL)
  2.         {
  3.             //print_r($where_values); echo '<br>';
  4.             echo "Estoy inicio select"; echo "<br>";
  5.             echo "Tabla: "; print_r($table); echo "<br>";
  6.             echo "Select_fields: "; print_r($select_fields); echo "<br>";
  7.             echo "Where_values: "; print_r($where_values); echo "<br>";
  8.             echo "Concat: "; print_r($concat); echo "<br>";
  9.            
  10.             if (!isset($table))
  11.             {
  12.                 die('Error in Db select');
  13.             }  
  14.             $query = 'SELECT';
  15.             if (isset($select_fields))
  16.             {
  17.                 $query .= ' '.implode(', ',$select_fields);
  18.             }
  19.             else
  20.             {
  21.                 $query .= ' *';
  22.             }
  23.             $query .= ' FROM '.$table;
  24.             echo "Query: "; print_r($query); echo "<br>";
  25.             if (isset($where_values) && isset($concat))
  26.             {
  27.  
  28.                 $keys = array_keys($where_values);
  29.                 $query .= ' WHERE';
  30.                 $first = TRUE;
  31.  
  32.                 foreach ($keys as $key)
  33.                 {
  34.                     // If field is a starting or ending interval, a '<' or '>' comparation is created.
  35.                     $arr = explode('_',$key);
  36.                     //print_r($arr); echo '<br>';
  37.                     $last = $arr[count($arr)-1];
  38.  
  39.                     if (strcmp($last,'startinterval')==0 || strcmp($last,'endinterval')==0)
  40.                     {
  41.                         echo "Se mete por intervals"; echo "<br>";
  42.                         unset($arr[count($arr)-1]);
  43.                         $field = implode('_',$arr);
  44.                         //echo ('CAMPO: '.$key.'<br>');
  45.                        
  46.                         if (strcmp($last,'startinterval')==0)
  47.                         {
  48.                             $op = '>=';
  49.                         }
  50.                         else
  51.                         {
  52.                             $op = '<=';
  53.                         }
  54.                         $condition = $field.$op.'?';
  55.                     }
  56.                     // If the field is a 'like' type, a LIKE comparation is created.
  57.                     else if (strcmp($last,'likeleft')==0 || strcmp($last,'likeright')==0 ||
  58.                         strcmp($last,'likeboth')==0)
  59.                     {
  60.                         echo "Se mete por like"; echo "<br>";
  61.                         unset($arr[count($arr)-1]);
  62.                         $field = implode('_',$arr);
  63.                         //echo ('CAMPO: '.$key.'<br>');
  64.                         $op = ' LIKE ';
  65.                        
  66.                        
  67.                         if (is_array($where_values[$key]))
  68.                         {
  69.                             $num_values = count($where_values[$key]);
  70.                             for($i=0; $i<$num_values; $i++)
  71.                             {
  72.                                 $where_values[$key][$i] = $this->replace_field_like($where_values[$key][$i], $last);
  73.                             }
  74.                            
  75.                         }
  76.                         else
  77.                         {
  78.                             $where_values[$key] = $this->replace_field_like($where_values[$key], $last);
  79.                         }
  80.                         $condition = $field.$op.'?';
  81.                     }
  82.                     else
  83.                     {  
  84.                         echo "Se mete por el ultimo else"; echo "<br>";
  85.                         echo "Keys: "; print_r($keys); echo "<br>";
  86.                         $condition = $key.'=?';
  87.                     }
  88.                     // Condition creation
  89.                     if ($first){
  90.                         $query.= ' ('.$condition;
  91.                         $first = FALSE;
  92.                     }
  93.                     else
  94.                     {
  95.                         $query.= ' '.$concat.' ('.$condition;
  96.                     }
  97.                     if (is_array($where_values[$key]))
  98.                     {
  99.                         $tmp_values = $where_values[$key];
  100.                         array_shift($tmp_values);
  101.                         $count = count($tmp_values);
  102.                         for ($i=0; $i<$count; $i++)
  103.                         {
  104.                             $query.= ' OR '.$condition;
  105.                         }
  106.                     }
  107.                     $query.=' )';
  108.                 }  
  109.             }
  110.             /*
  111.             if(isset($where_values))
  112.             {
  113.                 echo '['.$query.']<br>';
  114.                 //$where_values['blocked'] = '-1';
  115.                 print_r(flatten($where_values));
  116.             }*/
  117.             //echo '['.$query.']<br>';
  118.             try
  119.             {
  120.                 $result = $this->dbh->prepare($query);
  121.                 if (isset($where_values))
  122.                 {
  123.                     $where_values = array_values(flatten($where_values));
  124.                     echo "where_values: "; print_r($where_values); echo "<br>";
  125.                 }
  126.                 $result->execute($where_values);
  127.                 echo "Result: "; print_r($result); echo "<br>";
  128.                 //$rows = $result->fetchAll(PDO::FETCH_ASSOC);
  129.                 //echo "Rows: "; print_r($rows); echo "<br>";
  130.                 return $result;
  131.                
  132.             }
  133.             catch (PDOException $e)
  134.             {
  135.                 $this->fatal_error($e->getMessage());
  136.             }
  137.         }



Código PHP:
Ver original
  1. public function filter_rows($rows)
  2.         {
  3.             echo "Estoy inicio filter_rows"; echo "<br>";
  4.             echo "Rows: "; print_r($rows);
  5.             $date_fields = array(
  6.                 'loan_date','extention_date','last_status_change','last_info_update',
  7.                 'erd','lrw','part_status_update','sn_update','moved_history_date','request_date',
  8.                 'pickup_date','delivery_date','receipt_date','process_date','gidr_date',
  9.                 'operation_date','received_date','approval_date'
  10.             );
  11.            
  12.             $datetime_fields = array(
  13.                 'comment_date'
  14.             );
  15.            
  16.             $value_fields = array(
  17.                 'loan_value','operation_value','received_value'
  18.             );
  19.            
  20.             $num_rows = count($rows);
  21.            
  22.             for($i=0; $i<$num_rows; $i++)
  23.             {
  24.                 // Filter date fields
  25.                 foreach($date_fields as $field)
  26.                 {  
  27.                     if(isset($rows[$i][$field]))
  28.                     {
  29.                         //print_r ($rows[$i][$field].'<br>');  
  30.                         $rows[$i][$field] = format_date($rows[$i][$field]);
  31.                         //echo $rows[$i][$field].'<br>';
  32.                         /*
  33.                         if ($field=='request_date')
  34.                         {
  35.                             echo $rows[$i][$field];
  36.                         }
  37.                         */
  38.                     }
  39.                 }
  40.                
  41.                 // Filter datetime fields
  42.                 foreach($datetime_fields as $field)
  43.                 {  
  44.                     if(isset($rows[$i][$field]))
  45.                     {
  46.                         //print_r($rows[$i][$field]);  
  47.                         $rows[$i][$field] = format_datetime($rows[$i][$field]);
  48.                         //print_r($rows[$i][$field]);
  49.                         //echo '<br>';
  50.                     }
  51.                 }
  52.                
  53.                 // Filter value fields
  54.                 foreach($value_fields as $field)
  55.                 {  
  56.                     if(isset($rows[$i][$field]))
  57.                     {
  58.                         $rows[$i][$field] = str_replace('.',',',$rows[$i][$field]);
  59.                     }
  60.                 }
  61.                 // Filter text fields
  62.             }  
  63.             return $rows;
  64.         }
  65.        
  66.        
  67.     }

Tambien le pongo lo que la variable resultado tiene al final de la funcion, es decir antes del return.

Result: PDOStatement Object ( [queryString] => SELECT * FROM loan1 WHERE (loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? OR loan_id=? ) )

De todas formas analizando los resultados con menores elementos sale el mismo resultado con menos campos de loan_id=?.

Se me olvidaba también ponerle lo que contiene la variable where_values.

where_values: Array ( [0] => 75094 [1] => 76864 [2] => 77284 [3] => 78431 [4] => 82954 [5] => 83480 [6] => 84010 [7] => 84824 [8] => 86557 [9] => 86759 [10] => 87210 [11] => 88595 [12] => 89101 [13] => 89317 [14] => 88518 [15] => 127113 [16] => 128267 [17] => 120986 [18] => 126396 [19] => 123329 [20] => 125726 [21] => 128469 [22] => 121198 [23] => 121199 [24] => 123553 [25] => 123555 [26] => 123561 [27] => 123557 [28] => 123559 [29] => 123560 [30] => 123562 [31] => 122263 [32] => 123806 [33] => 121843 [34] => 125354 [35] => 124481 [36] => 124418 [37] => 122240 [38] => 124448 [39] => 124121 [40] => 125192 [41] => 125353 [42] => 123946 [43] => 123877 [44] => 125511 [45] => 128056 [46] => 130026 [47] => 125548 [48] => 128128 [49] => 120691 [50] => 121793 [51] => 127076 [52] => 122633 [53] => 121935 [54] => 122313 [55] => 124740 [56] => 125771 [57] => 125223 [58] => 123303 [59] => 123306 [60] => 125191 [61] => 125807 [62] => 123592 [63] => 124095 [64] => 27750 [65] => 34873 [66] => 75206 [67] => 127615 [68] => 127139 [69] => 127210 [70] => 127613 [71] => 127138 [72] => 125271 [73] => 126056 [74] => 128694 [75] => 128309 [76] => 128310 [77] => 128311 [78] => 128312 [79] => 128313 [80] => 128314 [81] => 128315 [82] => 128316 [83] => 128317 [84] => 128318 [85] => 128444 [86] => 128445 [87] => 128446 [88] => 85369 [89] => 85370 [90] => 85371 [91] => 89688 [92] => 89689 [93] => 89690 [94] => 89691 [95] => 89692 [96] => 89693 [97] => 85811 [98] => 85813 [99] => 81392 [100] => 81484 )

Por eso no tengo ni idea de que puede ser.

2) Si que tengo activado los errores y no me sale ningun tipo de error, es como si no hubiera nada en la consulta.

Un saludo.