如果没有SELECT GRANT,DELETE无法正常工作

时间:2017-06-16 10:34:38

标签: php mysql

我的MYSQL数据库中有2个用户。 intra_read授予了SELECTintra_writeDELETEUPDATE授予了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();
    }
}

有人知道为什么会发生这种情况并告诉我如何解决这个问题吗? 感谢。

1 个答案:

答案 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']}";