Re: DB_DataObject joining, sorting and ambiguous field name
| From: | Alan Knowles | Date: | Tue, 01 Nov 2005 00:33:54 +0000 |
| Subject: | Re: DB_DataObject joining, sorting and ambiguous field name | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-40367@lists.php.net to get a copy of this message | ||
On Mon, 2005-10-31 at 19:54 +0100, Olivier Guilyardi wrote:
> 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
issue this, beforehand.
$do1->selectAs();
- it removes the *,l and replaces it with all the real table column
names.
Regards
Alan
> - 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
>
--
Alan Knowles <alan@akbkhome.com>