execute页面上的示例2 是您想要的:
$sth->execute(array(':calories' => $calories, ':colour' => $colour));您可能也想看看其他示例。使用问号参数,将为:
$q = $dbc -> prepare("INSERT INTO accounts (username, email, password) VALUES (?, ?, ?)");$q->execute(array($_POST['username'], $_POST['email'], $_POST['password']));如果只有这些列,则可以编写:
$q = $dbc -> prepare("INSERT INTO accounts VALUES (?, ?, ?)");$q->execute(array($_POST['username'], $_POST['email'], $_POST['password']));


