1

我正在尝试使用以下代码更新表格,但总是到达rowcount并且0表格未更新。当我使用 phpmyadmin 时,相同的查询会更新表。

$query="UPDATE userprofile SET password=:newpassword WHERE userid=:userid AND password=:oldpassword";
$queryprepare=parent::getPreparedQuery($query);
$queryprepare->bindParam(':newpassword',$newpassword);
$queryprepare->bindParam(':userid',$userid);
$queryprepare->bindParam(':oldpassword',$oldpassword);
$queryprepare->execute();
4

1 回答 1

0

I'm not expert of PDO, but usual an UPDATE with no table modify depend on missing commit.

Which DB (and ISAM engine) do you use?

EDIT

looking at PDO manual I found this post of nils andre with my googelian maily accou: about the correct encoding of the connecction. I usual set all the chain (html-page, db-connection, db-column-type) with the same enconding (usually UTF-8) to avoid any problem.

In your case if your password contains some "binary" character the where will not match, so no update.

Simply remove the old-password condition to verify my hypothesis.

于 2012-06-30T10:33:02.063 回答