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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.