为什么即使我将一个字符串标记为“ i”(整数),也不能使bind_param失败?

时间:2019-09-27 08:09:03

标签: php mysqli prepared-statement php-7

我想知道即使我传递了一个字符串并且期望一个整数,下面的mysqli语句为什么仍然有效。

$id = "A";

$sql = "SELECT m.mandator_id, longname, shortname"
     . " FROM mandator m "
     . " WHERE mandator_id != ? "
     . " ORDER BY mandator_id";

$err = "";
if (!$stmt = $this->con->prepare($sql)) {
    $err .= "Prepare failed: (" . $this->con->errno . ") " . $this->con->error;
}
if (!$stmt->bind_param("i", $id)) {
    $err .= "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
...

我跳过了代码,但未达到“绑定参数失败”部分

                                    Type specification chars
     

字符说明

     

i |对应的变量具有整数类型

     

d |对应变量的类型为double

     

s |相应变量的类型为字符串

     

b |对应的变量是blob,将以数据包形式发送

Documentation

0 个答案:

没有答案