This topic is locked

Searching records

1/21/2021 5:02:39 PM
PHPRunner General questions
R
rfischerjr authorDevClub member

Table contains current_status field. In the List Page:Before SQL Query I have $strWhereClause = 'current_status = "Available" or current_status = "Pending Approval"'; to filter the list. The records are retrieved correctly from the table.
When I perform a simple search, the search is performed correctly, but the number of rows displayed in the list view does not change, i.e. if I have 500 total records, and 3 match my search criteria, (with highlight turned on) it will correctly highlight the 3 records, but you have to scroll through all 500 looking for them.
If I DELETE $strWhereClause = 'current_status = "Available" or current_status = "Pending Approval"'; from the List Page: Before SQL Query events, the search runs correctly and the list page displays only the 3 rows that match the search.
Is this expected behavior? If so - how can I filter the initial list to exclude records not matching Available / Pending Approval in the list view and still perform searches correctly??
If this is not expected behavior, where to look for what's causing the error??
Thank you in advance!

Sergey Kornilov admin 1/24/2021

Do not use BeforeSQLQuery event, it is not designed to handle this scenario.
Use the approach recommended in this article:

https://xlinesoft.com/phprunner/docs/dynamic_sql_query.htm