Maze Posted December 23, 2014 Share Posted December 23, 2014 hello dear php-experts, well i want to do some data-saving in the next few days. i have some data amount to store in a mysql-db. well i am pretty sure this is a easy question for php-freaks the question is: from plain-text to mysql-db: how to store a triple / array?how to store this data into a mysql-dbhave a dataset of 10 000 lines: {'data_1': 'data_2', 'data_3': 'data_4', 'data_5': 'data_6', 'data_7': 'data_8'} how to store this dataset into the mysql db ? love to hear from yougreetings Link to comment https://forums.phpfreaks.com/topic/293302-from-plain-text-to-mysql-db-how-to-store-a-triple-array/ Share on other sites More sharing options...
Barand Posted December 23, 2014 Share Posted December 23, 2014 What are the relationships between the entities represented by each line and those contained within each line? Link to comment https://forums.phpfreaks.com/topic/293302-from-plain-text-to-mysql-db-how-to-store-a-triple-array/#findComment-1500495 Share on other sites More sharing options...
Maze Posted December 23, 2014 Author Share Posted December 23, 2014 hello dear guru many thanks for the quick answer. well each line is a new data-chunk or - in python language a triple. eg like so: data = { 'url':alk, 'name':name, 'cname':capname } hope this may clear up a bit. - in case i need to provide more information - just let me know. have a great day Link to comment https://forums.phpfreaks.com/topic/293302-from-plain-text-to-mysql-db-how-to-store-a-triple-array/#findComment-1500499 Share on other sites More sharing options...
Barand Posted December 23, 2014 Share Posted December 23, 2014 Create a table "whatever" (where whatever is a meaningful name for the data) and load the data into it. Once it is in a table you can manipulate further if required. CREATE TABLE `whatever` ( `id` int(11) NOT NULL AUTO_INCREMENT, `url` varchar(255) DEFAULT NULL, `name` varchar(45) DEFAULT NULL, `cname` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) With the exception of the single quotes instead of double quotes, each line looks as though it is json encoded, so you could loop through each line, decode and insert into the table. Link to comment https://forums.phpfreaks.com/topic/293302-from-plain-text-to-mysql-db-how-to-store-a-triple-array/#findComment-1500503 Share on other sites More sharing options...
Maze Posted December 23, 2014 Author Share Posted December 23, 2014 hello dear barand many many thanks - great to see this. greetings matz Link to comment https://forums.phpfreaks.com/topic/293302-from-plain-text-to-mysql-db-how-to-store-a-triple-array/#findComment-1500528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.