elentz Posted November 24, 2016 Share Posted November 24, 2016 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 Quote Link to comment https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/ Share on other sites More sharing options...
mac_gyver Posted November 24, 2016 Share Posted November 24, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/#findComment-1539646 Share on other sites More sharing options...
elentz Posted November 24, 2016 Author Share Posted November 24, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/#findComment-1539650 Share on other sites More sharing options...
mac_gyver Posted November 24, 2016 Share Posted November 24, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/#findComment-1539653 Share on other sites More sharing options...
elentz Posted November 24, 2016 Author Share Posted November 24, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302608-large-number-of-fields-to-upload/#findComment-1539663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.