我正在尝试将数据库导出为CSV文件。 PHPmyadmin显示表只有大约25 MB。我尝试将全表导出分解为每次运行25000行。 (总计约为60k)。不确定导致问题的原因。显然fetch_assoc
导致了这种情况,但不确定原因。
if( count($this->input->post()) > 0 ){
$file = fopen("tmp/export.csv","w");
$query = "SELECT * FROM `data` WHERE export=0 LIMIT 2500";
$result = $this->db->query($query);
$row = $result->first_row('array');
//prepare the titles
$title =array();
$firstrow = array();
foreach ($row as $key => $value){
$title[] = $key;
$firstrow[] = $value;
}
//Write heading titles to the csv
fputcsv($file,$title);
fputcsv($file,$firstrow);
while($row = $result->next_row('array')){
$buffer = array();
foreach ($row as $items){
$buffer[]=$items;
}
fputcsv($file,$buffer);
}
fclose($file);
这是我得到的错误。 91个字节?
Fatal error: Out of memory (allocated 264503296) (tried to allocate 91 bytes) in /var/www/html/system/database/drivers/mysqli/mysqli_result.php on line 168
任何投入的人?