Casi lo estoy logrando pero me falta ayuda por favor
Código PHP:
Ver original$arraynamesexist = [];
$tables = $capsule::select('SHOW TABLES');
foreach ($tables as $key => $val) {
$tableName = (array)$val; }
$sqlScript = "";
foreach($arraynamesexist as $table){
$result = $capsule->table($table)->get();
$columnCount = count($result); $sqlScript.= '--';
$sqlScript.="\n";
$sqlScript.= '-- Estructura de tabla para la tabla `'.$table.'`';
$sqlScript.="\n";
$sqlScript.= '--';
$sqlScript.="\n";
$sqlScript.= 'DROP TABLE '.$table.';';
$sqlScript.= "\nCREATE TABLE ".$table.";\n\n";
$counter = 1;
for ($i = 0; $i < $columnCount; $i ++) {
foreach($result[$i] as $key=> $row){
$num_fields = count($row); if($counter == 1){
$sqlScript.= 'INSERT INTO '.$table.' VALUES(';
} else{
$sqlScript.= '(';
}
for ($j = 0; $j < $columnCount; $j ++) {
//$row[$j] = addslashes($row[$j]);
//$row[$j] = str_replace("\n","\\n",$row[$j]);
$sqlScript .= '"' . $row[$j] . '"';
} else {
$sqlScript .= '""';
}
if ($j < ($columnCount - 1)) {
$sqlScript .= ',';
}
}
$sqlScript .= ");\n";
++$counter;
}
}
$sqlScript.="\n";
}