How to remove htmlentities() values from the database?

前端 未结 6 1601
星月不相逢
星月不相逢 2021-02-08 04:42

Long before I knew anything - not that I know much even now - I desgined a web app in php which inserted data in my mysql database after running the values through htmlent

6条回答
  •  长发绾君心
    2021-02-08 04:48

    It's a bit kludgy but I think the mass update is the only way to go...

    $Query = "SELECT row_id, html_entitied_column FROM table";
    $result = mysql_query($Query, $connection);
    while($row = mysql_fetch_array($result)){
        $updatedValue = html_entity_decode($row['html_entitied_column']);
        $Query = "UPDATE table SET html_entitied_column = '" . $updatedValue . "' ";
        $Query .= "WHERE row_id = " . $row['row_id'];
        mysql_query($Query, $connection);
    }
    

    This is simplified, no error handling etc. Not sure what the processing time would be on millions of rows so you might need to break it up into chunks to avoid script timeouts.

提交回复
热议问题