This topic is locked
[SOLVED]

 Filter list before loading

8/3/2010 11:50:24 AM
PHPRunner General questions
K
kkiboo author

Whenever I view a table, (the List page), it loads all of the records from that table. Is there a way to filter those results before the list page loads so that only records with certain values in certain columns show up?
Aka Select * from Table where Column=xxx
How do I implement this?

A
ann 8/4/2010

Hi,
use Before SQL query event on the Events tab to filter records.

Here is a sample:

$strWhereClause = whereAdd($strWhereClause, "Column=xxx");
K
kkiboo author 8/4/2010

Thank you, that's exactly what I need.
You wouldn't by chance now how to include the now() function in that would you? The column I need to search from is a date column, I want to pull up records only relevant to the current day (so cannot be a static value). Is this possible?

A
ann 8/4/2010

Hi,
here is a sample for MySQL:

$strWhereClause = whereAdd($strWhereClause, "DateField=now()");



where DateField is your actual date field name.

K
kkiboo author 8/4/2010



Hi,
here is a sample for MySQL:

strWhereClause = whereAdd(strWhereClause, "DateField=now()");



where DateField is your actual date field name.


Thanks. When I input this into the BeforeSQL event, I get a synxtax error:
syntax error, unexpected '=' in line 3
Line 3 is the code:

strWhereClause = whereAdd(strWhereClause, "RECORD_DATE=sysdate");


I double tested it by running it anyway, and it gives the error in output too.

K
kkiboo author 8/4/2010

Also, just to check, I changed it to this:


$strWhereClause = whereAdd(strWhereClause, "RECORD_DATE=sysdate");


The syntax is ok, but when I build it and run it I get a PHP error citing an undefined constant (strWhereClause).
Thanks in advance for any help!

A
ann 8/4/2010

Hi,
replace strWhereClause with $strWhereClause.

If it doesn't help please zip and send your project file to support@xlinesoft.com for investigation.

K
kkiboo author 8/4/2010



Also, just to check, I changed it to this:


$strWhereClause = whereAdd(strWhereClause, "RECORD_DATE=sysdate");


The syntax is ok, but when I build it and run it I get a PHP error citing an undefined constant (strWhereClause).
Thanks in advance for any help!


$strWhereClause = whereAdd($strWhereClause, "AUDIT_DATE=sysdate");
I copy and pasted, I guess originally both of the $s were forgotten. Oh well, thanks for all your help, you're wonderful!

romaldus 9/1/2010



Hi,
use Before SQL query event on the Events tab to filter records.

Here is a sample:

$strWhereClause = whereAdd($strWhereClause, "Column=xxx");



But how i filter list based on logged GroupID (dynamic permission)?
EXAMPLE_TABLE

FILELD1..FILELD2..FILELD2..GroupID..
Please take a look at this post for $_SESSION["CustomGroupID"] :

http://www.asprunner.com/forums/topic/15048-sessiongroupid-for-dynamic-permission/

A
ann 9/1/2010

Romaldus,
here is a sample of filtering based on the logged user (Before SQL query event):

$rstmp = CustomQuery("select GroupID from ugmembers where UserName='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_array($rstmp);

$strWhereClause = whereAdd($strWhereClause, "groupid=".$datatmp["GroupID"]);
romaldus 9/1/2010



Romaldus,
here is a sample of filtering based on the logged user (Before SQL query event):

$rstmp = CustomQuery("select GroupID from ugmembers where UserName='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_array($rstmp);

$strWhereClause = whereAdd($strWhereClause, "groupid=".$datatmp["GroupID"]);



ERROR after add the custom code :



D
Dale 9/1/2010

Yours to date in your code
$strWhereClause = whereAdd($strWhereClause, "groupid=".$datatmp["GroupID"]);
Try adding the quotes around $datatmp["GroupID"] as below
$strWhereClause = whereAdd($strWhereClause, "groupid='".$datatmp["GroupID"]."'");
Just a quick shot at it

romaldus 9/1/2010



Yours to date in your code
$strWhereClause = whereAdd($strWhereClause, "groupid=".$datatmp["GroupID"]);
Try adding the quotes around $datatmp["GroupID"] as below
$strWhereClause = whereAdd($strWhereClause, "groupid='".$datatmp["GroupID"]."'");
Just a quick shot at it


Thanks Dale.. but not work

romaldus 9/2/2010

[quote name='romaldus' date='02 September 2010 - 07:54 AM' timestamp='1283388859' post='52342']
I've tried to add the quotes around $datatmp["GroupID"] bot not work...

A
ann 9/8/2010

Hi,
It's difficult to tell you what's happening without seeing actual files.

Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.

W
wildwally 9/9/2010

anyone able to shed some light on this subject? trying to do the same thing.