This topic is locked

Dynamically add where clause to the search suggest

9/22/2010 7:27:22 PM
PHPRunner General questions
D
Dale author

Hopefully someone can point me to the file I need to modify here.
I have a table of items. I use a addwhere clause in the before process sql to only get records mathing the current session language.

Displays the list perfectly.
But when I do a quick search, the ajax dropdown list displays results from all items in the table.
How do I add the addwhere clause to the search suggest.
I have the same issue, when viewing a list that you have a Masterlink relationship, when you have the list displayed, along with the master detail information, again when you do a quick search, you are returned values from the entire list and not just items within the masterdetail details.
In the older versions I could add the clause to the autosuggest.php file, I have no idea where I would deal with this in the version 5.2.
Suggestions.

D
Dale author 9/23/2010

No pointers.

A
ann 9/28/2010

DaleM,
you'll need to create custom view for the table on the Datasource tables tab and redirect to this view on language selection.

Modify the Edit SQL query tab of the view.

D
Dale author 9/28/2010

This is killing me. I have spent two days now trying to track down WHERE the ajax routines get the sql string when fetching records.
I have a list that I come to through from a mastertable link. It works perfectly when you come through the link. It works perfectly when refreshing the page. But when I change the number of records to display on page, it then returns all the records. Loosing the mastertable link and thus loosing the where clause. It also does this if I click the quick search button without any value entered. It should still only show records belonging to the master detail.

If I used the advanced search on this page, not even search, just return to list, I get all records showing.

If I am on the correct list after coming through the masterlink, IF I select view or edit of a record, on coming back all the records display again.
I have enabled debug mode, I have used printing of the session variables to see if mastertable and masterkey are still valid.

Everything is in order.

WHAT I CANT SEE, is any values (the sql and where clauses) it is using when doing an ajax fetch.
I have been in more files than there are snowflakes.
Where can I possibly track the ajax request. Like I said this is killing me and putting me really behind in this project.

Im lost, worried and behind the gun. Any help would be appreciated.
Im not to sure if your answer Ann is what I am looking for, I just want to add this same dissappearing where clauses to the ajax search suggest also.

Im hoping I can do that if I can figure out what the hey is going on with this list.

Sergey Kornilov admin 9/29/2010

Dale,
I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com providing all required info on reproducing this issue. This is not a support forum and we cannot guarantee timely and accurate answers here.

F
FunkDaddy 11/16/2010

I'm taking the liberty to post DaleM's response to a inquiry I made to him directly regarding this post.
From DaleM:

------

I found in the After table initialized event, a $tdataitem[".sqlWhereExpr"] and also you have access to the gsqlFrom, $gsqlWhereExpr and the $gsglTail variables.
I found is I stuck my where clause in the $tdataitem[".sqlWhereExpr"], same value in the and also built the $gsqlWhereExpr.

Filled the $gsglTail variable with $strSQLorder
Now my autosuggest will only suggest values from the currently displayed list.

As I said, I just debugged it by echoing the above mentioned variabels and then I stuffed what i wanted into them.
It works pretty good.

I hope this is enough explanation, Im into a project right now full bore and I dont have much time to do other things.

The actual code snippet is on my development box. If you need more, just contact me again, and I will cut and paste the code I used.
Dale

F
FunkDaddy 11/16/2010

Shortly before you replied I tried something that worked perfectly for me. I edited the "searchsuggest.php" file that is located in the root folder of my application output folder by adding appending the where clause in that file.
For example, I added the following line right after line #93 of that file:



$where .=" AND LinkCompanyID= " . $_SESSION["LinkCompanyID"];


I have not tried Dale's suggestion yet but sounds like it works as well.
Best,