小编smu*_*unt的帖子

条件 PDO 绑定参数更新

因此,我正在尝试进行条件更新,但我似乎在将数据与语句绑定时遇到问题。

功能:

function updateEditor($email, $first, $last, $id){
global $DBH;
$response = false;
$upemail = "";
$upfirst = "";
$uplast = "";

$stmt = "SELECT memEmail, memFirst, memLast FROM MEMBER WHERE memID = :id";
try{
    $STH = $DBH->prepare($stmt);
    $STH->bindParam(':id', $id);
    $STH->execute();

    $STH->setFetchMode(PDO::FETCH_ASSOC);
    $row = $STH->fetch();
    if($row['memEmail'] != $email){ $upemail = $email;}
    if($row['memFirst'] != $first){ $upfirst = $first;}
    if($row['memLast'] != $last){ $uplast = $last;}

}catch(PDOException $e) {
    echo $e->getMessage() . "first";

}
$stmt .= "UPDATE MEMBER SET ";
if(!empty($upemail)){
    $stmt .= "memEmail …
Run Code Online (Sandbox Code Playgroud)

php mysql pdo

1
推荐指数
1
解决办法
529
查看次数

标签 统计

mysql ×1

pdo ×1

php ×1