Jeroen
|
| Posted: 07/07/2002, 8:13 AM |
|
Hi,
I have a question about executing SELECT in CCS using PHP + templates.
I have a huge database of 900000 rows. And I've build a search + grid.
The problem is that the search works with 'like %..%'. So automaticly when I open the page it does a "SELECT * FROM table WHERE column LIKE %$s_column%" or something. So, when you open the page the script selects all the rows. And this takes very long, because there are so many rows. How do I build a check so it won't do a SELECT when the page opens and/or the search box is empty?
I've tried to add 'if($s_column == "") {' to 'Before execute SELECT' and '}' to 'After execute SELECT'. But that doesn't work.
|
|
|
 |
Chris K.
|
| Posted: 07/07/2002, 11:33 AM |
|
Your solution could work in CC, but in CCS events are executes as functions.
In CCS you could try to add in Before Build Select grid's event:
global $<formname>;
if (CCGetFromGet("s_column","") === "")
$<formname>.ds.Where = "0";
Replace <formname> with name of your form. This expression will append always false component to your where clause if no search specified.
You could alternatively add some message to DataSource's Errors collection to prevent query from execution
|
|
|
 |
Chris K.
|
| Posted: 07/07/2002, 11:50 AM |
|
Oops, sorry, porting from ASP...
Expression should be:
global $<formname>;
if (CCGetFromGet("s_column","") === "")
$<formname>->ds->Where = "0";
|
|
|
 |
Jeroen
|
| Posted: 07/07/2002, 12:17 PM |
|
Thanks!
This works great.
|
|
|
 |
|