This topic is locked

setSearchOption bugged

2/5/2020 9:42:02 AM
PHPRunner General questions
S
silk author

Hello,

I'm trying to set a default date range for recors on a list page. I use the following code in "After table initialized" of the "news" table to get records of the last 5 days:
FIRST BUG:



$srchObj = SearchClause::getSearchObject("news_table")
$srchObj->setSearchOption("newsdate", BETWEEN);

$srchObj->setFieldValue("newsdate",date("Y-m-d",strtotime('-5 days')) );

$srchObj->setSecondFieldValue("newsdate",date("Y-m-d") );


I tried also with



$srchObj->setSearchOption("newsdate", MORE_THAN);


In both cases I get the search field formatted as an "equal" field and the code does not work.
SECOND BUG:

I use european dates (d/m/Y). If I pass the date in this format the first field of the between seacrh does not work, but the second does.

If I pass dates in the format Y-m-d as in the code above, the first field work but the second doesn't.
Does anybody have any workaround until the functionality will be fixed? Thanks!

N
Nir Frumer 2/5/2020



Hello,

I'm trying to set a default date range for recors on a list page. I use the following code in "After table initialized" of the "news" table to get records of the last 5 days:
FIRST BUG:



$srchObj = SearchClause::getSearchObject("news_table")
$srchObj->setSearchOption("newsdate", BETWEEN);

$srchObj->setFieldValue("newsdate",date("Y-m-d",strtotime('-5 days')) );

$srchObj->setSecondFieldValue("newsdate",date("Y-m-d") );


I tried also with



$srchObj->setSearchOption("newsdate", MORE_THAN);


In both cases I get the search field formatted as an "equal" field and the code does not work.
SECOND BUG:

I use european dates (d/m/Y). If I pass the date in this format the first field of the between seacrh does not work, but the second does.

If I pass dates in the format Y-m-d as in the code above, the first field work but the second doesn't.
Does anybody have any workaround until the functionality will be fixed? Thanks!


hi

I would try doing it as a tab on the list page

1st tab "last 5 days", 2nd tab "All"
hope it helps,

Nir.

S
silk author 2/6/2020



hi

I would try doing it as a tab on the list page

1st tab "last 5 days", 2nd tab "All"
hope it helps,

Nir.


Thanks for the suggestion, but I'm doing it to speed up list page loading (it's a huge DB) and the user must be able to change the date directly on the list page to avoid loading all records

lefty 2/6/2020



Thanks for the suggestion, but I'm doing it to speed up list page loading (it's a huge DB) and the user must be able to change the date directly on the list page to avoid loading all records


As a workaround:
If MySQL and you don't want tabs , create a custom view of the news table and in query designer add - WHERE clause.
, then use your main table for all records. You can add indexes to your news table in PHPmyadmin to speed up large data.
If Sql server then. WHERE[font="Consolas,"][size="2"] newsdate BETWEEN[/size]

S
silk author 2/6/2020



If MySQL and you don't want tabs , create a custom view of the news table and in query designer add - WHERE clause.
, then use your main table for all records. You can add indexes to your news table in PHPmyadmin to speed up large data.
If Sql server then. WHERE[font="Consolas,"][size="2"] newsdate BETWEEN[/size]


thanks John, but if I add the where condition in query designer I cannot use search on list page to see older records. I want the page to load with a preset search field of BETWEEN 5 days ago and today, then the user can change dates. (I already added indexes in mysql)