Jump to content

Recursively change database field names with PHP


RopeADope

Recommended Posts

Hi all.

 

The title pretty much says it all.  I really have no idea if this is even possible or where to start.  A recent dilemma caused me to have to change a field name with some spaces in it.  I have a database with ~65 tables, a majority of which were converted from Access.  So I'm curious as to how many others have bad field names.  Is there a way to use PHP to go through all the field names in a database and remove spaces?

Link to comment
Share on other sites

Is there a way to use PHP to go through all the field names in a database and remove spaces?

 

yes. you can use SQL to get the column names of each table, then look for spaces in those column names. if spaces are found, remove or replace the space in the field name, then MODIFY TABLE to change the field name from the old name to the new name.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.