DB_DataObject joining, sorting and ambiguous field name
| From: | Olivier Guilyardi | Date: | Mon, 31 Oct 2005 18:54:41 +0000 |
| Subject: | DB_DataObject joining, sorting and ambiguous field name | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-40364@lists.php.net to get a copy of this message | ||
Hi,
Allessandro Pasotti has reported problems with sorting, when using
Structures_DataGrid over joined DataObjects.
See the following bug report :
http://pear.php.net/bugs/bug.php?id=5606
I have analyzed this bug (look at the bottom of the bug report) and believe that
DB_DataObject could be configured to properly distinguish between fields coming
from one table or another.
This configuration should be done right before passing the DataObject to the
DataGrid, and if properly done there shouldn't be such sorting troubles.
I have tried to do such configuration using the DB_DataObject::selectAs()
method, but it failed :
- both my tables have a 'name' field
- I issue a $do1->selectAs($do2, 'do2_%s')
- DBDO generates a query like : "SELECT *, name as do2_name ..."
- when the datagrid tries to sort by 'name', MySQL says the field name is
ambiguous,
- but the datagrid can sort the table using "do2_name"
I tried some other things, but before writing a novel... What do you think about
this ? Is this a DBDO bug or missing feature ?
--
og