我的MYSQL数据库中有2个用户。 intra_read
授予了SELECT
,intra_write
,DELETE
和UPDATE
授予了INSERT
。但遗憾的是,如果我授予他intra_write
,我可以删除SELECT
行。
private function getphaseOutIDs($connection) {
$sql = "SELECT Mitarb_ID FROM infoMail WHERE ref_date<NOW()";
$statement = $connection->prepare($sql);
$statement->execute();
return $erg = $statement->fetch(PDO::FETCH_ASSOC);
}
public function deletePhaseOutIDs($connectionWrite,$connectionRead) {
while ($row = $this->getphaseOutIDs($connectionRead)) {
$sql = "DELETE FROM infoMail WHERE Mitarb_ID=" . $row['Mitarb_ID'];
$statment = $connectionWrite->prepare($sql);
$statment->execute();
}
}
有人知道为什么会发生这种情况并告诉我如何解决这个问题吗? 感谢。
答案 0 :(得分:0)
不应该这样:
$sql = "DELETE FROM infoMail WHERE Mitarb_ID=" . $row['Mitarb_ID'];
尝试此查询:
$sql = "DELETE FROM infoMail WHERE Mitarb_ID='". $row['Mitarb_ID'].'"";
或者
$sql = "DELETE FROM infoMail WHERE Mitarb_ID= {$row['Mitarb_ID']}";