| Import script?? 
 
	 
	
		| Author | Message |   
		| unknowngiver 
 
 
 
 
 | 
			
				|  Posted: Tue Jul 04, 2006 3:14 pm    Post subject: Import script?? |  |   
				| 
 |  
				| hey i have two databases!
 one is running through a script..and one is just a database with a table!
 
 The second database [without a script] has alot of Game cheats and i wanted to import them into my running database...but they both have different structures, i know its possible to do it because i have seen pplz convert from PHPBB to IPB to Vbulletin which all have different my sql structures!!
 here are the two structures:
 
 Structure of the database that i am running:
 
 	  | code: |  	  | 
CREATE TABLE `dd_items` (
 `ItemID` int(10) NOT NULL auto_increment,
 `ItemTitle` varchar(255) NOT NULL default '',
 `ItemCategory` int(10) NOT NULL default '0',
 `ItemSubcategory` int(10) NOT NULL default '0',
 `ItemText` text,
 `ItemImage` varchar(255) NOT NULL default '',
 `Contributor` varchar(50) NOT NULL default '',
 `DateAdded` int(10) NOT NULL default '0',
 `ItemType` varchar(10) NOT NULL default '',
 `ItemStatus` varchar(20) NOT NULL default 'unapproved',
 PRIMARY KEY  (`ItemID`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=253 ;
 
 | 
 Structure of the database that i want to import
 
 	  | code: |  	  | 
CREATE TABLE `pcgames` (
 `id` bigint(20) NOT NULL auto_increment,
 `cheattitle` varchar(255) NOT NULL default '',
 `category` varchar(200) NOT NULL default 'PC_Games',
 `gametitle` varchar(244) NOT NULL default '',
 `cheatcode` text NOT NULL,
 `author` varchar(255) NOT NULL default '',
 `date` varchar(58) NOT NULL default '',
 PRIMARY KEY  (`id`),
 FULLTEXT KEY `cheattitle` (`cheattitle`,`category`,`gametitle`,`cheatcode`,`author`)
 ) TYPE=MyISAM AUTO_INCREMENT=3005 ;
 
 | 
 can anyone help me out on this?
 thanks
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| rdrake 
 
  
 
 
 | 
			
				|  Posted: Tue Jul 04, 2006 8:37 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Just create a connection to both databases, then retrieve the data from the one and place it in the other. 
 So, you just get the information from the information database, then insert that info into your new database.  Just make the necessary conversions in structure then.  Something like as follows.	  | code: |  	  | <?php
// Connect to the server
 $server = mysql_connect(host, username, password);
 $database_1 = mysql_select_db(database1, $server);
 $database_2 = mysql_select_db(database2, $server);
 
 $result = mysql_query("SELECT * FROM yourinfodatabase");
 
 // Take the results from the information database
 // Insert this info into your empty database which the script uses
 ?>
 | 
 
 Just remember to change it to your needs.  I haven't used PHP in a while, and I'm feeling lazy at the moment.	  | code: |  	  | mysql_query("INSERT INTO newdatabase VALUES (\'" . $result['id'] . "\', \'" . $result['submitter'] . "\')"); | 
 
 Oh, and just a quick suggestion.  For the following line, typically the id column is named just id.  Many frameworks (ie. Rails) expect it to be this way, and it's a good habit to follow that.
 Of course, that is just a suggestion	  | code: |  	  |   `ItemID` int(10) NOT NULL auto_increment,  | 
  . 
 Good luck.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| octopi 
 
  
 
 
 | 
			
				|  Posted: Wed Jul 05, 2006 5:04 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Hello, 
 Heres what I'd do, I'd make a new table that is the maximum for each field.
 
 Then I'd use a program like mysql front for windows, it lets you connect to a database and export data, and then you can connect to the other and import it.
 
 You could do it in php, but doing it with mysql-front is way easier.
 
 If you want me to do it, pm me and I can help ya out.
 
 http://www.mysqlfront.de/
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| unknowngiver 
 
 
 
 
 | 
			
				|  Posted: Tue Jul 11, 2006 8:17 pm    Post subject: (No subject) |  |   
				| 
 |  
				| hey guyz i tried but couldnt get it ...can anyone add me and guide me through it? please and thank you
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |