Q:

How can i fetch all data from any table of a test DB and DUMP it on the production db in same tablename(structure)?

How can i fetch all data from any table of a test DB and DUMP it on the production db in same tablename(structure)? in Mysql using PHP code?
Please help me..

EDIT

I need PHP to do this for me using MySQL Queries

A:

Sorry, a little disorganized but these are the functions I use to build the SQL code for table reconstruction and repopulating. This is all within a 'table' object but I'm sure you can piece together what's going on.
The SQL "SHOW CREATE TABLE yourtablename" gives you everything needed to create the table again. All the rest is just looping through all the entries and making INSERT statements.
public function backup() {
    $output = "/* - - - Table recovery for $this->tablename - - - */\n\n\n";
    $output .= "DROP TABLE IF EXISTS `$this->tablename`;\n\n";
    $output .= $this->showcreate().';';
    $output .= $this->showrepopulate();
    return $output."\n\n\n";
}        

final protected function showcreate() {
    $result = $this->query("SHOW CREATE TABLE $this->tablename");
    return $result[0]['Create Table'];
}

final protected function showrepopulate() {
    $result = $this->query("SELECT * FROM $this->tablename");
    $output = '';
    $count = count($result);
    if ($count) {
        $output = "\n\nINSERT INTO `$this->tablename` VALUES\n";
        for ($i=0; $i<$count; $i++) {
            $output .= "(";
            $numfields = count($result[$i]);
            for ($j=0; $j<$numfields; $j++) {
                if ($j>0) $output .= ',';
                $output .= $this->Database->escape(array_shift($result[$i]));
            }
            $output .= ")";
            $output .= ($i != $count-1) ? ",\n" : ';';
        }
    }
    return $output;
}

