The Little Guy Posted November 19, 2010 Share Posted November 19, 2010 I am making a php script that will copy all the tables from a database on host A and copying them to another database on host A or on host B (depending on the users selections). I want to allow the user to select whether or not they want the "structure and data" or just the "structure" copied. What is the best way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/ Share on other sites More sharing options...
fenway Posted November 21, 2010 Share Posted November 21, 2010 I don't understand which side of the script you're asking for help with. Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137532 Share on other sites More sharing options...
The Little Guy Posted November 21, 2010 Author Share Posted November 21, 2010 I don't understand which side of the script you're asking for help with. I don't understand what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137560 Share on other sites More sharing options...
fenway Posted November 21, 2010 Share Posted November 21, 2010 Do you have the front-end? the back-end? is something broken? is this a design question? Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137561 Share on other sites More sharing options...
ignace Posted November 21, 2010 Share Posted November 21, 2010 We need some more information regarding what you are trying to achieve. You can use HeidiSQL if you want to transfer data manually from remote host to remote host or MySQL supports Replication if you want data to be always copied from one database to another. Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137606 Share on other sites More sharing options...
The Little Guy Posted November 21, 2010 Author Share Posted November 21, 2010 I am working on a project, and I have a database administration page. Currently on this page you can change the connection settings (host, username, password, database) from 4 text fields. The second section (see attachment), is a "database copier", and the section pertaining to this question. In this section the user enters in the "host", "username", "password", and "database" of where the current database will be copied to. They also choose if they want the structure and data of all the tables copied, or just the structure of all the tables copied. Next they press "Copy" and it copies it all to the new database! I am not sure what is the best way to copy, or even how to copy the database, so that is basically my question. How, and what way should I do this? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137641 Share on other sites More sharing options...
ignace Posted November 21, 2010 Share Posted November 21, 2010 How: SHOW TABLES FROM <database>; SHOW CREATE TABLE <table>; SHOW COLUMNS FROM <table>; What: Use mysql_unbuffered_query() to read the row and insert the row into the new table on the remote host. Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137649 Share on other sites More sharing options...
fenway Posted November 21, 2010 Share Posted November 21, 2010 Dare I ask why you're letting users create copies of a database? Quote Link to comment https://forums.phpfreaks.com/topic/219242-coping-a-database/#findComment-1137665 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.