Guest User

Untitled

a guest
Jul 17th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. $hostname = "localhost";
  2. $username = "db_username";
  3. $password = "db_password";
  4. $database = "db_name";
  5.  
  6. mysql_connect($hostname, $username, $password);
  7.  
  8. // The find and replace strings.
  9. $find = "find_this_text";
  10. $replace = "replace_with_this_text";
  11.  
  12. $loop = mysql_query("
  13. SELECT
  14. concat('UPDATE ',table_schema,'.',table_name, ' SET ',column_name, '=replace(',column_name,', ''{$find}'', ''{$replace}'');') AS s
  15. FROM
  16. information_schema.columns
  17. WHERE
  18. table_schema = '{$database}'")
  19. or die ('Cant loop through dbfields: ' . mysql_error());
  20.  
  21. while ($query = mysql_fetch_assoc($loop))
  22. {
  23. mysql_query($query['s']);
  24. }
Add Comment
Please, Sign In to add comment