Using wildcards in prepared statement - MySQLi

后端 未结 5 830
无人及你
无人及你 2020-11-27 23:14

I\'m trying to run the following query, and I\'m having trouble with the wildcard.

   function getStudents() {
        global $db;
        $users = array();
         


        
5条回答
  •  無奈伤痛
    2020-11-28 00:00

    Another way to do this is:

    SELECT id, adminRights FROM users 
      WHERE classes LIKE CONCAT("%", ?, "%") && adminRights='student'
    

    This is handy in case you have a dynamic result bind and only want to change the SQL query...

提交回复
热议问题