 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
jannie00
Joined: 07 Apr 2008 Posts: 6
|
Posted: Mon Apr 07, 2008 5:43 pm Post subject: setDefaultSort problem with two identical column names, MDB2 |
|
|
Hello,
I use the MDB2 datasource in combination with DataGrid and have the following problem:
If have a query with two identical column names like:
SELECT
a.name AS aname,
b.name AS bname
FROM
a,
b
WHERE
a.id = b.id
When I do in my PHP code:
...
$DataGrid->setDefaultSort(array(
'name' => 'DESC'
));
$DataGrid->bind($query, $options);
...
I get the MDB2 error:
Column 'name' in order clause is ambiguous
Even when I remove 'b.name AS bname' from the query I get the error message. Also tried to use the alias ('aname') as default sort, same error. Has anyone a solution? Is it a bug? Do I have to change one of the column names in the database (rather not, it is used a lot)?
Regards, Chris |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Mon Apr 07, 2008 10:44 pm Post subject: Re: setDefaultSort problem with two identical column names, |
|
|
| jannie00 wrote: | [...]I get the MDB2 error:
Column 'name' in order clause is ambiguous
Even when I remove 'b.name AS bname' from the query I get the error message. |
That is expected behaviour so far. Both tables have a column with this name, and you're selecting from both tables ("FROM a, b").
| jannie00 wrote: | | Also tried to use the alias ('aname') as default sort, same error. Has anyone a solution? Is it a bug? |
Using the alias in the setDefaultSort() call would have been my advise. Are you really sure that you get the same error? Could it maybe be caused by another part of your query?
Using $error->getDebugInfo() in addition to $error->getMessage() will give you more details, and should also give you the "broken" query. Can also please paste the reported query here?
($error needs to be replaced, of course, it's just an example) |
|
| Back to top |
|
 |
jannie00
Joined: 07 Apr 2008 Posts: 6
|
Posted: Wed Apr 09, 2008 10:41 am Post subject: |
|
|
You are right. It does work now when using the alias. Something else in the query was causing the error.
Sometimes you just need a good nights sleep...
Regards, Chris |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|