更新查询未在面向对象的php mysqli中更新

时间:2019-07-01 10:14:31

标签: php mysql

不幸的是,我尝试使用新的加密总线更新更新密码,代码未更新

我尝试过 $conn->execute(),但这是一个错误。

function update_password()
{
    $start = microtime(true);
    $conn = new mysqli('localhost', 'root', '123456', 'mydb');

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

        $sql = "SELECT id, password FROM user WHERE new_password IS NULL LIMIT 1000;";

        $pass_array = $conn->query($sql);

        if ($pass_array->num_rows == 0) {
            $time_elapsed_secs = microtime(true) - $start;
            echo "Found like its finished processing";
            echo $time_elapsed_secs;
            return true;
        } else {
            while ($row = $pass_array->fetch_assoc()) {
                $a1 = new MyCypher2();
                $pass = $a1->decryptData($row['password']);
                $a2 = new MyCypher();
                $pass_ennew = $a2->encrypt($pass);
                $sql2 = "UPDATE `user` SET `password` = '".$pass_ennew. "', `new_password` = 1 WHERE = ".$row['id'].";";
                $conn->query($sql2);
            }
        }

    $conn->close();
}

0 个答案:

没有答案