使用GAE cloud sql更新PHP mySQL

使用GAE cloud sql更新PHP mySQL,php,mysql,sql,google-app-engine,cloud,Php,Mysql,Sql,Google App Engine,Cloud,Persons表有一个名为“data”的字段和另一个名为“id”的字段,该字段会自动递增。 它有一个条目,我正在尝试更新该条目。 我正在使用GAE Cloud Sql for php。 我成功连接到数据库,然后执行以下操作: $data="Please do not go."; try { $stmt = $db->prepare('INSERT INTO Persons (data) VALUES (:theData)');

Persons表有一个名为“data”的字段和另一个名为“id”的字段,该字段会自动递增。 它有一个条目,我正在尝试更新该条目。 我正在使用GAE Cloud Sql for php。 我成功连接到数据库,然后执行以下操作:

$data="Please do not go.";

try {
                   $stmt = $db->prepare('INSERT INTO Persons (data) VALUES (:theData)');
                   $stmt->execute(array(':theData' => htmlspecialchars($data)));
                   $affected_rows = $stmt->rowCount();
                   // Log $affected_rows.
} catch (PDOException $ex) {
                    // Log error.
                    die(json_encode(
                    array('outcome' => false, 'message' => 'PIE.')
                    )
                    );
}

$data="Please go away.";

try {
          $stmt = $db->prepare('UPDATE Persons (data) VALUES (:theData) WHERE id=1');
          $stmt->execute(array(':theData' => htmlspecialchars($data)));
} catch (PDOException $ex) {
          // Log error.
          die(json_encode(
                    array('outcome' => false, 'message' => 'LOL YOU FAILED')
                    )
                    );
}

foreach($db->query('SELECT * from Persons') as $row) {

                    echo $row['data'];

}

$db = null;
输出为:

请不要走

而不是:

请走开

我用来更新表的代码有什么问题吗?

更新
,因为它不像使用
关键字的
插入

UPDATE [LOW_PRIORITY] [IGNORE] table_reference
    SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]
而是希望使用
SET

UPDATE Persons SET data = :theData WHERE id=1;