how to use addToQuery() and filter()
Permalink
I created my List model. That extended DatabaseItemList library.
In that I set my base query like
When I use the following query in my controller
It adds "where 1=1" and I keep getting sql error.
The addToQuery() content is primary key and foreign key relation.
How to solve this problem...
In that I set my base query like
protected function setBaseQuery() { $this->setQuery('SELECT table1.col1, table3.col2, table1.col2, table2.col1 FROM table1, table2, table3'); }
When I use the following query in my controller
$List->addToQuery("where table2.col1 = table1.col3 and table3.col1 = table1.col2");
It adds "where 1=1" and I keep getting sql error.
The addToQuery() content is primary key and foreign key relation.
How to solve this problem...
I just saw that the other question was posted in a protected area, here's my answer I've posted there:
---
use ANSI SQL - it's easier to read, looks nicer and doesn't need an additional addToQuery:
I'm not sure I got the column names right..
---
use ANSI SQL - it's easier to read, looks nicer and doesn't need an additional addToQuery:
protected function setBaseQuery() { $this->setQuery('SELECT table1.col1, table3.col2, table1.col2, table2.col1 FROM table1 INNER JOIN table2 ON tabl1.col2=table2.col1 INNER JOIN table3 ON table2.col1 = table3.col1'); }
I'm not sure I got the column names right..
Sorry Remo,
I first posted at here only...
I did not get any response... So, I posted at Leaders Discussion forum...
I don't know how to delete it...
Non-Community members cannot view that page...
So, it may helpful to all community members also... ;-)
I first posted at here only...
I did not get any response... So, I posted at Leaders Discussion forum...
I don't know how to delete it...
Non-Community members cannot view that page...
So, it may helpful to all community members also... ;-)
at least make sure that you add a comment to both posts telling others that you've asked it before..
Ok Remo, Thanks for your information...
I have Another query...
If I want to use Between clause using filter query...
How to do that?
Any syntax is there for that?
If I want to use Between clause using filter query...
How to do that?
Any syntax is there for that?
For any other situation where you need to add something to the WHERE clause that can't be expressed as a filter, use the following:
Using the above example:
$list->postUserQuery = 'additional SQL';
Using the above example:
$List->postUserQuery('where table2.col1 = table1.col3 and table3.col1 = table1.col2');
Is this new? I don't see this in the API at all. I see that its used in DatabaseItemList but that property is protected and there is no way of altering it
http://www.concrete5.org/developers/pro-accounts/community-leaders-...