Sorry, but i'm new to PHP, so i will look like a noob.
As the title says, i made this method which updates user data:
function update($userid, $name){
Try{
$stmt=$this->db->prepare("UPDATE users
SET
name=:name,
WHERE userid=:userid");
$stmt->execute(array(':name'=>$name));
} Catch(PDOException $e){
echo $e->getMessage();
}
}
That code is working right, but i want to know if it's possible, the "name" column just update if the variable coming from:
$user->update($userid, $name);
From $name, is not null or not empty. If it's null or Empty, the MYSQL UPDATE function should not be done.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…