PDOでデータをupdate

まずは”?”を使って更新します。

<?php

$dsn = "mysql:dbname=stock;host=localhost";
$user = "root";
$password = "";
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET CHARACTER SET 'utf8'");
try {
	$dbh = new PDO($dsn, $user, $password, $options);
} catch (PDOException $e){
	print('connection failed:'.$e->getMessage());
}

$sql = "select stoph SET 'price' = ? WHERE id = ?";
$stmt = $dbh->prepare($sql);

$stmt->execute(array(430, 2929));
?>