Home » Database » DB_DataObject » Bug #6953
toArray() problem
Details
| Submitted | 2006-02-27 20:38 UTC |
|---|---|
| From | lamengual at sitrack dot com |
| Status | No Feedback |
| Package | DB_DataObject |
| PHP Version | 4.4.1 |
| OS | Windows XP |
| Roadmaps | (Not assigned) |
Comments
[2006-02-27 20:38 UTC] lamengual at sitrack dot com
Description:
------------
When there's a query with joins and you use a while( $do->fetch() ) structure the function toArray() does not works properly. The last time the while statement process the fetch() function, the global variable $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]) is unsetted and the toArray() function brings data from $do->table and not from the global variable.
Test script:
---------------
...
$usuario = DB_DataObject::factory('usuario');
$persona = DB_DataObject::factory('persona');
$persona->nombre = "Luis";
$persona->joinAdd( $usuario );
$persona->find();
while( $persona->fetch() ){
...
}
//El toArray no imprime los campos de usuario + persona
echo '<pre>';
print_r( $persona->toArray() );
echo '</pre>';
Expected result:
----------------
Array
(
[personaid] => 2412
[direccionid] =>
[nombre] => Luis
[apellido] => Agüero
[documentotipoid] => 1
[documento] => 14.119.339
[observacion] => Socio Gerente
[usuarioid] => 3319
[accesonombre] => Luis Agüero
[accesoclave] => patan
[clienteid] => 1315
[usuariotipoid] => 2
[disclaimer] => 0
[keepalive] => 1
[perfilid] => 6
[idiomaid] => es
[fechaformatoid] => 1
[zonahorariaid] => 1
[skinid] => 1
[veranuncio] => 0
[activo] => 1
[gisperfilid] => 2
[ultimases] =>
[fechaultimases] =>
[contadorses] => 0
)
Actual result:
--------------
Array
(
[personaid] => 2412
[direccionid] =>
[nombre] => Luis
[apellido] => Agüero
[documentotipoid] => 1
[documento] => 14.119.339
[observacion] => Socio Gerente
)