Using wildcards in prepared statement - MySQLi

后端 未结 5 833
无人及你
无人及你 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:03

    You have to pass parameters to bind_param() by reference, which means you have to pass a single variable (not a concatenated string). There's no reason you can't construct such a variable specifically to pass in, though:

    $className = '%' . $this->className . '%';
    $query->bind_param('s', $className);
    

提交回复
热议问题