This topic is locked
[SOLVED]

 $strWhereClause in Before SQL Query with OR statement not working

9/8/2017 4:15:37 AM
PHPRunner General questions
S
seedavidwork author

I have added a query to filter my table based on the logged in user_id which I have set with a session variable user_id_s.

When I apply this statement the results are as expected only showing the records that match.

$strWhereClause = whereAdd($strWhereClause, "estimator_id ='" .$_SESSION["user_id_s"] ."'");


I wanted to look at other fields using a OR statement, but the page returns every record.

$strWhereClause = whereAdd($strWhereClause, "estimator_id OR job_pmid OR job_reviewby='" .$_SESSION["user_id_s"] ."'");


When I run this as a Query on the Database I see the results I expect, but when I add this to my Before SQL Query event the query fails.
Any advice on how to construct a where statement that I can use in the Before SQL Query event which will return a record if either of my three fields match the session variable?

admin 9/8/2017

Here is how you need to change it:



$strWhereClause = whereAdd($strWhereClause, "estimator_id='" .$_SESSION["user_id_s"] ."' OR job_pmid='" .$_SESSION["user_id_s"] ."' OR job_reviewby='" .$_SESSION["user_id_s"] ."'");