在PHP中使用PDO,我们限制使用哪些字符.我试过在文档和在线查找,但无济于事.
我找到了一个帖子,其中一个用户在名称中使用了一个打破了查询的超级用户.我正在编写一个动态生成这些名称的函数,因为连字符不是nos,我想知道是否有一个备选列表.
<?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();
?>
Run Code Online (Sandbox Code Playgroud)
那么在这个例子中,字符串':color'中允许哪些字符?
我面对 Invalid parameter number: parameter was not defined
是因为这个吗?
和
(
(orders.hour_begin >= :begin_hour and orders.hour_final <= :hour_final )
or
(orders.hour_begin <= :begin_hour and orders.hour_final > :hour_final )
or
(orders.date_final > :hour_final and orders.hour_final <= :hour_final )
or
(orders.hour_begin >= :begin_hour and orders.hour_final <= :hour_final )
)
Run Code Online (Sandbox Code Playgroud)
我在数组中定义了相同的参数
array('begin_hour' => $begin_hour, 'hour_final' => $hour_final)
Run Code Online (Sandbox Code Playgroud)