$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更新permalink失败,名称:Funding Circle的故事,permalink:Funding circles的故事
更新permalink失败,故事id:199,名称:Rentah,permalink:Rentah-1