在带有 PDO 的 PHP 中,我们限制使用哪些字符。我尝试查看文档和在线但无济于事。
我确实发现了一篇文章,其中用户在名称中使用了连字符,这破坏了查询。我正在编写一个动态生成这些名称的函数,并且由于连字符不是 no,我想知道是否有替代列表。
<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour');
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();
?>
那么在此示例中,字符串“:colour”中允许使用哪些字符?
最佳答案
关于php - PDO 占位符的有效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55642110/