Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Bug GetRowAssoc ADODB?

Estas en el tema de Bug GetRowAssoc ADODB? en el foro de PHP en Foros del Web. Estoy usando php 5.2 ( la ultima que permite usar mssql.dll) La version de ADODB 5.18a (La mas reciente) Resuelta que dependiendo si uso GetRowAssoc ...
  #1 (permalink)  
Antiguo 04/04/2013, 10:29
Avatar de h2swider  
Fecha de Ingreso: julio-2007
Ubicación: Ciudad de Buenos Aires
Mensajes: 932
Antigüedad: 16 años, 8 meses
Puntos: 194
Bug GetRowAssoc ADODB?

Estoy usando php 5.2 ( la ultima que permite usar mssql.dll)

La version de ADODB 5.18a (La mas reciente)

Resuelta que dependiendo si uso GetRowAssoc o FetchRow varían la cantidad de campos en el resultado, teniendo que ser los mismos, cambiando los indices de asociativos a numericos.

GetRowAssoc me da 10 columnas, mientras FetchRow 14 (esta es la correcta)

Lamentablemente necesito recuperar los nombres de las columnas, precisando el uso de GetRowAssoc.

¿Alguno sabe si ADODB tiene un bug que me pueda estar afectando con mssql?
¿O encuentran alguna falencia mia
Les muestro el ejemplo:

Código PHP:
$params = array('beneficio' => 'xxxxxxxxxx''gp' => 'xx');
$result = array();

$stmt $this->db->PrepareSP('sp_TOL_ObtenerDatosAfiliados');

$this->db->InParameter($stmt$params['beneficio'], 'p_Beneficiario');
$this->db->InParameter($stmt$params['gp'], 'p_GP');

$rs $this->db->Execute($stmt);

while (!
$rs->EOF) {
    
$result[] = $rs->GetRowAssoc(false);
    
$rs->MoveNext();

Código var_dump:
Ver original
  1. array(2) {
  2.   [0]=>
  3.   array(10) {
  4.     ["idhc"]=>
  5.     int(1016)
  6.     ["apellido"]=>
  7.     string(2) "NO"
  8.     ["nombre"]=>
  9.     NULL
  10.     ["tipodocumento"]=>
  11.     string(2) "DN"
  12.     ["numerodocumento"]=>
  13.     string(8) "03770106"
  14.     ["historiaclinica"]=>
  15.     string(4) "1016"
  16.     ["telefono"]=>
  17.     NULL
  18.     ["telefonoalternativo"]=>
  19.     NULL
  20.     ["telefonoalternativo2"]=>
  21.     NULL
  22.     ["email"]=>
  23.     NULL
  24.   }
  25.   [1]=>
  26.   array(10) {
  27.     ["idhc"]=>
  28.     int(1016)
  29.     ["apellido"]=>
  30.     string(1) "."
  31.     ["nombre"]=>
  32.     NULL
  33.     ["tipodocumento"]=>
  34.     string(2) "DN"
  35.     ["numerodocumento"]=>
  36.     string(8) "03770106"
  37.     ["historiaclinica"]=>
  38.     string(4) "1016"
  39.     ["telefono"]=>
  40.     NULL
  41.     ["telefonoalternativo"]=>
  42.     NULL
  43.     ["telefonoalternativo2"]=>
  44.     NULL
  45.     ["email"]=>
  46.     NULL
  47.   }
  48. }

Código PHP:
$params = array('beneficio' => 'xxxxxxxxxx''gp' => 'xx');
$result = array();

$stmt $this->db->PrepareSP('sp_TOL_ObtenerDatosAfiliados');

$this->db->InParameter($stmt$params['beneficio'], 'p_Beneficiario');
$this->db->InParameter($stmt$params['gp'], 'p_GP');

$rs $this->db->Execute($stmt);

while (
$arr $rs->FetchRow()) {
    
$result[] = $arr;

Código var_dump:
Ver original
  1. array(2) {
  2.   [0]=>
  3.   array(14) {
  4.     [0]=>
  5.     int(1016)
  6.     [1]=>
  7.     string(9) "FISCHETTI"
  8.     [2]=>
  9.     string(5) "MIRTA"
  10.     [3]=>
  11.     string(2) "DN"
  12.     [4]=>
  13.     string(8) "03770106"
  14.     [5]=>
  15.     string(4) "1016"
  16.     [6]=>
  17.     string(8) "49195240"
  18.     [7]=>
  19.     NULL
  20.     [8]=>
  21.     NULL
  22.     [9]=>
  23.     NULL
  24.     [10]=>
  25.     string(2) "NO"
  26.     [11]=>
  27.     NULL
  28.     [12]=>
  29.     NULL
  30.     [13]=>
  31.     NULL
  32.   }
  33.   [1]=>
  34.   array(14) {
  35.     [0]=>
  36.     int(1016)
  37.     [1]=>
  38.     string(9) "FISCHETTI"
  39.     [2]=>
  40.     string(5) "MIRTA"
  41.     [3]=>
  42.     string(2) "DN"
  43.     [4]=>
  44.     string(8) "03770106"
  45.     [5]=>
  46.     string(4) "1016"
  47.     [6]=>
  48.     string(8) "49195240"
  49.     [7]=>
  50.     NULL
  51.     [8]=>
  52.     NULL
  53.     [9]=>
  54.     NULL
  55.     [10]=>
  56.     string(1) "."
  57.     [11]=>
  58.     NULL
  59.     [12]=>
  60.     NULL
  61.     [13]=>
  62.     NULL
  63.   }
  64. }
__________________
Codifica siempre como si la persona que finalmente mantedra tu código sea un psicópata violento que sabe donde vives
  #2 (permalink)  
Antiguo 04/04/2013, 11:11
Avatar de h2swider  
Fecha de Ingreso: julio-2007
Ubicación: Ciudad de Buenos Aires
Mensajes: 932
Antigüedad: 16 años, 8 meses
Puntos: 194
Respuesta: Bug GetRowAssoc ADODB?

Primeramente si existia un bug.
http://phplens.com/lens/lensforum/msgs.php?id=17539

En segunda instancia, ADODB no reconoce caracteres que no sean alfanuméricos almenos en MSsql. Entonces columnas como "numero_1" no son resueltas correctamente.

Evitar ese tipo de nomenclatura y no deberían tener problemas
__________________
Codifica siempre como si la persona que finalmente mantedra tu código sea un psicópata violento que sabe donde vives

Etiquetas: bug, sql
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 17:11.