diff options
Diffstat (limited to 'export.php')
| -rw-r--r-- | export.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/export.php b/export.php new file mode 100644 index 0000000..b9cdfac --- /dev/null +++ b/export.php @@ -0,0 +1,24 @@ +<?php + +$dbh = new PDO('mysql:host=localhost;dbname=mdcc', 'mdcc', 'Mdcc.'); + +$filename = '/var/www/dighelaw.com/www/mdcc/csv_exports/mdcc_export.csv'; + +header('Content-Type: text/csv'); +header("Content-Disposition: attachment; filename={$filename}"); +header('Pragma: no-cache'); + +$sql = $_REQUEST['sql']; +$sql .= " INTO OUTFILE '{$filename}'"; + +$st = $dbh->prepare($sql); +if ( $st->execute() ) { + readfile($filename); +} else { + $errors = $st->errorInfo(); + print_r($errors); +} + +unlink($filename); + +?> |
