Jump to content

Recommended Posts

I have a list of approx 400 new fields I need to create in a new table.  They can all be varchar 40 for the most part.  I have the list in a csv.  I can find all sorts of ways to upload the file as data but nothing to create fields out of the list I have.  I am looking for suggestions / solutions on how to get this done.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/
Share on other sites

you would produce the correct ALTER TABLE or CREATE TABLE query and execute it, provided that you can even create a database user on your hosting that has permission to alter/create a database table.

 

however, everything you are asking points to a bad design. you shouldn't be dynamically creating tables/adding columns. 400 fields/columns in one table would be highly unusual and in it self indicates the data isn't being properly normalized (databases are not spreadsheets and trying to use them as one results in a lot of complicated code and queries to accomplish even simple tasks.)

 

care to share some relevant information about what you are doing and a sample of the columns/fields you intend to dynamically add to a table?

I am in need of a method to provision VoIP phones.  The cfg file I need to create has approx 430 potential entries.  I plan on using a php page to enter the info and then use a query to get the info into the DB.  The fields I asked about will be static.  I have complete control over the server, I am using Centos6, Apache and MySql  So is there a limit to the number of fields in a table?  I could break up the number of fields into different tables.  When all is said and done I need to put it all together and create a file to configure the phone.  

there is a limit to the amount of data in one row.

 

for what you have described, you would store each data item in its own row, with phone_id,  config_id, and value columns. to retrieve the set of data for any phone, you would just query for the rows having that phone's id value. the phones and configuration names would be defined in other tables, giving the phone_id and config_id to use in the configuration storage table. 

It will actually be easier than you imagine.  There will be a common "template" that will create all the buttons and the common features of the phone.  Each phone cfg file will be identical with the exception of the extension # and a password..  The cfg file will be named with the MAC address of the phone.  

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.