更新查询不起作用

时间:2014-09-23 11:20:37

标签: php mysql pdo

我试图用PDO写一个更新查询,但它不起作用

for ($count = 0; $count < 4; $count++) {
        if (!trim($elements[$count])=='') {

                $query = "update servers set " . '?' . "=" . '?' . "where " . '?'  . "=" . '?';
                $pdo = new PDO($db->dsn, 'adp', 'pass');
                $stmt = $pdo->prepare($query);
                $stmt->bindParam(1, $index[$count]);
                $stmt->bindParam(2, $elements[$count]);
                $stmt->bindParam(3, $index[$count]);
                $stmt->bindParam(4, $ServerName);
                $stmt->execute();
          }
}

1 个答案:

答案 0 :(得分:1)

表和列名称不能由PDO中的参数替换。有关详细信息,请参阅this answer