I have a situation like this:
if ( $level == 1 ) {
$type = '0';
} elseif ( $level == 2 ) {
$type = '1';
} elseif ( $level == 3 ) {
$type = '(2 or type = 1)'; // This part does not work.
} elseif ( $level == 10 ){
$type = '3';
} else {
return false;
}
$sqlFindParent = 'select count(id) as parent from datable where id = :parent and uType = :type and countryCode = :countryCode';
$findParent = $conn->prepare($sqlFindParent);
$findParent->bindParam(':type',$type);
$type is dynamic. When I bind it, it does not work when it comes to elseif ( $level ==3 )
because of the or
in there. Sure, I could use in
, but do you have a better way to do this using or
itself?