php - How to parametrize SQL query with multiple WHERE conditions (prepared statement)?
问题 I have multiple conditions in WHERE clause which are inputted by user (call them filters ). Currently I am processing them this way (don't worry it isn't deployed): //$by_nickname etc. are filters from $_GET $conditions = array(); if($by_nickname !="") { $conditions[] = " players.lastName LIKE ('%" . $by_nickname . "%')"; } if($by_steamid !="") { $conditions[] = " ids.uniqueId = '$by_steamid'"; } if($by_ip !="") { $conditions[] = " players.lastAddress = '$by_ip'"; } if($by_msg !="") {