This topic is locked
[SOLVED]

$query->addWhere Question

5/20/2022 5:25:43 PM
PHPRunner General questions
P
ppradhan@live.com author

Hi all,
In the After Table Initialized event, below 1 & 2 code works well (1 condition, 2 condition).
But the 3rd code does not work (3 conditions). ANY suggestions is highly appreciated.

  1. $query->addWhere("counsellor_assigned= '".$_SESSION["ID"]." ')
  2. $query->addWhere("counsellor_assigned= '".$_SESSION["ID"]."' and status != 'dropped'")
  3. $query->addWhere("counsellor_assigned= '".$_SESSION["ID"]."' and status != 'dropped' or status != 'Enrolled'")

Sergey Kornilov admin 5/20/2022

Your logic in #3 doesn't make any sense. You are trying to select records where status doesn't equal 'dropped' OR status doesn't equal 'Enrolled', which means all records will be displayed every time. You need to rethink your logic or you need to explain it in plain English so someone can assist you.

P
ppradhan@live.com author 5/20/2022

I realized that OR should not be used in $query->addWhere(condition) and all OR are to be replaced by AND.
Got it working now.