Possible DB_DataObject bug with joins
| From: | cron at odi dot com dot br | Date: | Tue, 21 Nov 2006 18:06:00 +0000 |
| Subject: | Possible DB_DataObject bug with joins | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25894@lists.php.net to get a copy of this message | ||
$usuario = DB_DataObject::factory("usuario");
$regional = DB_DataObject::factory("regional");
$usuario->strnome = "nome33";
$usuario->joinAdd($regional, "INNER", "regional", "idregional");
usuario->selectAs(array('id','strregional'),
"regional_%s","regional");
Resulting select
SELECT *, regional.id as regional_id , regional.strregional as
regional_strregional
FROM usuario
INNER JOIN regional ON regional.id=usuario.idregional
WHERE ( strnome ILIKE '%nome33%' )
Note the *, fields. Does not matter if i use selectAs to select only 2 fields,
the * will return all fields from all tables in the join.
Not elegant fix, fit it is a fix:
Replace (line 2563):
return $class;
Width:
$objClass = new $class;
$objClass->_query['data_select'] = $table . ".*";
return $objClass;
Ps: No idea if it has collateral damages.
Cron