How do I create a PDO parameterized query with a LIKE statement?

后端 未结 7 1301
眼角桃花
眼角桃花 2020-11-22 04:47

Here\'s my attempt at it:

$query = $database->prepare(\'SELECT * FROM table WHERE column LIKE \"?%\"\');

$query->execute(array(\'value\'));

while ($r         


        
7条回答
  •  甜味超标
    2020-11-22 05:06

    Figured it out right after I posted:

    $query = $database->prepare('SELECT * FROM table WHERE column LIKE ?');
    $query->execute(array('value%'));
    
    while ($results = $query->fetch())
    {
        echo $results['column'];
    }
    

提交回复
热议问题