On 11/4/2010 8:32 AM, p...@blu-studio.com wrote:
I am wondering if anyone has had to search an entire database and do a search
and replace on a string. That is to search in every table, in every row, in
every field.
The simplest way will be to loop through the tables in php (use SHOW
TABLES), constructing & executing an UPDATE statement for each one like:
UPDATE table SET
field1=REPLACE(field1,'from','to'),
...
fieldN=REPLACE(fieldN,'from','to');
You can use DESCRIBE TABLE table; to get the list of fields, and to cut
them down to only the fields containing text based on the field type.
Dan
_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/Show-Participation