如何从数据库中提取记录、调整它们并将它们插入到不同的列中?

How can I pull records out of the database, adjust them and insert them into a different column?

我需要从我的数据库中提取故事名称 table(故事),将它们更改为 url 友好格式(权力的游戏 --> 权力的游戏)并将它们插入同一 table (story.permalink) 中的不同列。有没有好的方法来做到这一点?我来自 mac 终端的 运行 当前 php 功能无法正常工作。

$conn = update_dao_connect();
$get_stmt = $conn->prepare("select id, name from story");
$update_stmt = $conn->prepare("update story set permalink=? where id=?");
$update_stmt->bind_param("si", $permalink, $id);
if($get_stmt->execute()){
    $get_stmt->bind_result($id, $name);
    while($get_stmt->fetch()){
        $permalink = generate_story_permalink($name);
        if(!$update_stmt->execute()){
            error_log("update permalink failed for kamp id: ".$id.", name: ".$name.", permalink: ".$permalink);
        }
    }
}
else {
    error_log("execute get all story for copy_story_names_to_permalinks fail");
}

终端输出(对于数据库中的所有记录):
更新永久链接失败,故事 ID:198,名称:Funding Circle 的故事,永久链接:funding-circles-story
更新永久链接失败,故事 ID:199,名称:Rentah,永久链接:rentah-1
更新永久链接失败,故事 ID:200,名称:Kano Computing,永久链接:kano-computing
更新永久链接失败,故事 ID:201,名称:Outplacement,永久链接:outplacement-1

提前致谢!

解决方法是添加$get_stmt->store_result();在 $get_stmt->execute(); 之后就像这个答案 Commands out of sync; you can't run this command now