| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/thelittlebigshow/app/admin/ |
Upload File : |
<?php
session_start();
require_once 'config/config.php';
require_once BASE_PATH . '/includes/auth_validate.php';
$db = getDbInstance();
$select = array('id', 'name', 'address', 'phone', 'vehicle_maker', 'vehicle_model', 'vehicle_year', 'signature', 'qrcode', 'created_date');
$chunk_size = 100;
$offset = 0;
$data = $db->withTotalCount()->get('vehicles');
$total_count = $db->totalCount;
$handle = fopen('php://memory', 'w');
fputcsv($handle,$select);
$filename = 'export_customers.csv';
$num_queries = ($total_count/$chunk_size) + 1;
//Prevent memory leak for large number of rows by using limit and offset :
for ($i=0; $i<$num_queries; $i++){
$rows = $db->get('vehicles',Array($offset,$chunk_size), $select);
$offset = $offset + $chunk_size;
foreach ($rows as $row) {
fputcsv($handle,array_values($row));
}
}
// reset the file pointer to the start of the file
fseek($handle, 0);
// tell the browser it's going to be a csv file
header('Content-Type: application/csv');
// Save instead of displaying csv string
header('Content-Disposition: attachment; filename="'.$filename.'";');
//Send the generated csv lines directly to browser
fpassthru($handle);