Re: [PHP] Search/Replace in entire database?
[email protected] (tedd)
| Newsgroups | php.general |
|---|---|
| Message-ID | <p06240800c65bee6d2011@[192.168.1.102]> |
At 9:17 PM -0700 6/14/09, Chris Payne wrote: >Hi everyone, > >I am in the middle of creating an editor where you can search and >replace on an individual column in a single table then I came across >something I need to be able to do but not sure how. > >Is it posible (And if so please how :-) to search an entire database >and all tables within a database and do a find/replace on keywords >without having to specify each table/column within that table? > >The people I am working for have made some big changes and one of them >is changing the names of one of their products, but this product name >appears EVERYWHERE in many tables and in lots of different column >names, and it would save so much time if I could do a single query >that would just search EVERYTHING within the database. > >Thanks for any advice you can give me. > >Regards > >Chris Payne Chris: The problem you cite is exactly why one should use relational databases. If the people you are working for had done that, then you would have only to edit one table. The process works like this -- you have a product table that has an unique id with other information about each product, such as its name. However, every table that references that product does so via the product's id and not the product's name. As such, each look-up for the product name requires first to know the product's id and then pull out the name associated with that id. In any event, a little more work at the start saves tons later. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com