i am building a script to migrate data from a dbase file to a mysql table, but with some files (large ones) it gives me this error:
Fatal error: Out of memory (allocated -1678508032) (tried to allocate 64 bytes) in D:\wamp\www\dbf2MySql\LeerDbase.php on line 65
This is the code
echo "Por favor espere...<br/>";
for ($valor = 1; $valor <= count($archivos); $valor++) {
//echo $valor;
//echo $archivos[$valor]; echo "<br/>";
$fichero_dbf = "tmp/". $archivos[$valor];
$conex = dbase_open($fichero_dbf, 0); //abro el archivo
if($conex){ //si la conexión es buena, realizo la migración
$arrData = array();
$total_registros = dbase_numrecords($conex);
for ($i = 1; $i <= $total_registros; $i++){
$arrData[] = dbase_get_record($conex,$i); //<-- Here is the memory error line
}
// Obtener la información de columna
$info_columna = dbase_get_header_info($conex);
//Busco los titulos o cabeceras
for ($i = 0; $i < count($info_columna); $i++) {
$titulos[$i] = $info_columna[$i]['name'];
if (in_array($info_columna[$i]['name'], $titulos)) {
$titulos[$i] = $info_columna[$i]['name']."_".$i;
}
}
//print_r($titulos);
//echo DibujarTabla($titulos, $arrData);
$arreglo = explode(".", $archivos[$valor]);
//Paso los datos a mysql
CrearTablaMySql($arreglo[0], $dbf2MySql, $titulos, $arrData, $database_dbf2MySql, $total_registros);
}else{
echo "No se pudo acceder al fichero dbf -> '" . $fichero_dbf . "'<br/>"; //Si me da un error muestro un error
}
dbase_close($conex); //Cierro la conexión al archivo
if ($valor == (count($archivos))) {
echo "FINALIZADO";
mysqli_close($dbf2MySql);
}
}
Any help would be appreciated, let me know if you need more info to help me solve this issue
EDITED
UPDATE
I use now command line, but i get this error now using php.exe
D:\wamp\bin\php\php5.5.12>php.exe -f "D:\wamp\www\dbf2MySql\CommandScript.php" errmxite.dbf Por favor espere...
Fatal error: Call to undefined function dbase_open() in D:\wamp\www\dbf2MySql\Co mmandScript.php on line 33
Call Stack: 0.0007 273304 1. {main}() D:\wamp\www\dbf2MySql\CommandScript.php:0
Here is the updated code
SOLUTION
I used php command line to execute the scripts with some changes, and now it works without issues, thanks to all