
-----------------------------------
unknowngiver
Tue Jul 04, 2006 3:14 pm

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 
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

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

-----------------------------------
rdrake
Tue Jul 04, 2006 8:37 pm


-----------------------------------
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.
mysql_query("INSERT INTO newdatabase VALUES (\'" . $result['id'] . "\', \'" . $result['submitter'] . "\')");Just remember to change it to your needs.  I haven't used PHP in a while, and I'm feeling lazy at the moment.

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.  `ItemID` int(10) NOT NULL auto_increment, Of course, that is just a suggestion :).

Good luck.

-----------------------------------
octopi
Wed Jul 05, 2006 5:04 pm


-----------------------------------
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
Tue Jul 11, 2006 8:17 pm


-----------------------------------
hey guyz
i tried but couldnt get it ...can anyone add me and guide me through it? please and thank you
