Export mysql database tables to php code to create same tables in other database?
- by chefnelone
How do I Export mysql database tables to php code so that it allows me to create and populate same tables in other database?
I have a local database, I exported to sql syntax, then I get something like:
CREATE TABLE `boletinSuscritos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(120) NOT NULL,
`email` varchar(120) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
INSERT INTO `boletinSuscritos` VALUES(1, 'walter', '[email protected]', '2010-03-24 12:53:12');
INSERT INTO `boletinSuscritos` VALUES(2, 'Paco', '[email protected]', '2010-03-24 12:56:56');
but I need it to be: (Is there any way to export the tables in this way)
$sql = "CREATE TABLE boletinSuscritos (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(120) NOT NULL,
email varchar(120) NOT NULL,
date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ( id )
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 )";
mysql_query($sql,$conexion);
mysql_query("INSERT INTO boletinSuscritos VALUES(1, 'walter', '[email protected]', '2010-03-24 12:53:12')");
mysql_query("INSERT INTO boletinSuscritos VALUES(2, 'Paco', '[email protected]', '2010-03-24 12:56:56')");