Con la funcion de abajo respaldo una copia de mi base de datos, pero me pasa algo muy curioso: Si la realizo en el servidor local, responde:
INSERT INTO calendario(huesped) VALUES("muñoz Gómez");
En el servidor remoto:
INSERT INTO calendario(huesped) VALUES("muñoz Gómez");
misma estructura BD,misma version php 7.0, ????
¡¡¡ NO LO ENTIENDO!!!
Gracias
Código PHP:
function backupDatabaseTables($dbHost,$dbUsername,$dbPassword,$dbName,$tables = '*'){ //connect & select the database $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
//get all of the tables
if($tables == '*'){
$tables = array();
$result = $db->query("SHOW TABLES");
while($row = $result->fetch_row()){
$tables[] = $row[0];
}
}else{
$tables = is_array($tables)?$tables:explode(',',$tables);
}
//loop through the tables
foreach($tables as $table){
$result = $db->query("SELECT * FROM $table");
$numColumns = $result->field_count;
$return .= "DROP TABLE IF EXISTS $table;";
$campos2=mysqli_query($db, "SELECT COLUMN_NAME as columna FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table' and table_schema = 'trinid_alquiler' " );
$a=0;
while ($campos= mysqli_fetch_assoc($campos2)){ if ($a < ($numColumns-1)) {$retur.=$campos['columna'].",";}else{$retur.=$campos['columna'];} $a++; } $result2 = $db->query("SHOW CREATE TABLE $table"); $row2 = $result2->fetch_row();
$return .= "\n\n".$row2[1].";\n\n";
for($i = 0; $i < $numColumns; $i++){
while($row = $result->fetch_row()){
$return .= "INSERT INTO $table";
$return .= "(".$retur.")";
$return.=" VALUES(";
for($j=0; $j < $numColumns; $j++){
//$row[$j] = addslashes($row[$j]);
if (isset($row[$j]) and ($row[$j]!=="")){ $return .= '"'.$row[$j].'"' ; }
else if(is_null($row[$j] )) { $return .= 'NULL'; }
else { $return .= '""'; }
if ($j < ($numColumns-1)) { $return.= ','; }
}
$return .= ");\n";
}$retur="";
}
$return .= "\n\n\n";
}