I have situation like I need to move several rows of data from table in my local database to a remote database. The situation is:
that data may be varies from hundreds to several thousand hundreds. Using queries in PHP to select, then delete, then insert into remote machine will take too long time to do this process.
Expecting there could be a better solution for this, but don't know..
Could anybody suggest me how to do this.
Hope I understand what you are trying to get at? I am amusing you know PHP. When the page loads query the first DB and use results to populate form fields. When the form is submitted you can than insert the data into the next DB. You can do this all from one page.
Example query on page load
include '../connect-db.php';
$query = "SELECT * FROM `DB`
WHERE id='".$mysqli->real_escape_string($_REQUEST['id'])."'
limit 0,1";
//execute the query
$result = $mysqli->query( $query );
//get the result
$row = $result->fetch_assoc();
//assign the result to certain variable so our html form will be filled up with values
$id = $row['id'];
$name = $row['name'];
populated HTML Form
<form action=# method='post' name=ra id=ra>
<table>
<tr>
<th><h1 class='whatever'><?php echo $name;?></h1></th>
</tr>
<tr>
<input type='hidden' name='action' value='update' />
<input type='submit' value='Update' /></td></tr></table>
Insert Query on submit
if($action=='update' ){
include '../connect-new-db.php';
$query = "insert into `DB`
set
`name` = '".$mysqli->real_escape_string($_POST['name'])."',
`link` = '".$mysqli->real_escape_string($_POST['link'])."'";
//execute the query
if( $mysqli->query($query) ) {
//if saving success
echo "<h2>The data has been added.</h2>";
}else{
//if unable to create new record
echo "<h2>There has been an error adding the data</h2>";
}
}
Hope that Helps