Alter many files, all with same variable in them

Reply

Join Date: Dec 2006
Posts: 48
Reputation: woocha is an unknown quantity at this point 
Solved Threads: 0
woocha's Avatar
woocha woocha is offline Offline
Light Poster

Alter many files, all with same variable in them

 
0
  #1
Jan 17th, 2008
I have 100's of files that access a field in a mySQL DataBase. I had to change the field name and now I have to update 100's of files. The files read:
  1. $sql = 'SELECT user_id, username, user_colour, user_birthday FROM '
I need it to now read:
  1. $sql = 'SELECT id, nick, user_colour, user_birthday FROM '

I know I could go through all files and execute a replace 'user_id' with 'id', but that would take forever. Does anyone know a program to do this easier?
Last edited by woocha; Jan 17th, 2008 at 11:04 am.
FREE Online Auctions At:
http://www.woocha.com/auctions
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 84
Reputation: johnsquibb is an unknown quantity at this point 
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: Alter many files, all with same variable in them

 
0
  #2
Jan 17th, 2008
Off the top of my head, Dreamweaver has a search and replace (CTRL-F) function that will allow you to batch replace an entire folder/website/etc.

While you are finding and replacing, you might consider replacing 100 instances of the same code with an include path to a single script to make future revisions less painful.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,425
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 231
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Alter many files, all with same variable in them

 
0
  #3
Jan 17th, 2008
If you're on linux then grep is your friend. Also as Johnsquibb said, if you have probably over 5 instances of identical code, put it in one file then just include it.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 48
Reputation: woocha is an unknown quantity at this point 
Solved Threads: 0
woocha's Avatar
woocha woocha is offline Offline
Light Poster

Re: Alter many files, all with same variable in them

 
0
  #4
Jan 17th, 2008
Originally Posted by johnsquibb View Post
Off the top of my head, Dreamweaver has a search and replace (CTRL-F) function that will allow you to batch replace an entire folder/website/etc.

While you are finding and replacing, you might consider replacing 100 instances of the same code with an include path to a single script to make future revisions less painful.
Hey..that sounds like a good idea. Do you have any advise on how to get started with something like that
FREE Online Auctions At:
http://www.woocha.com/auctions
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC