3.4.0-rc1
[phpmyadmin/thilanka.git] / tbl_get_field.php
bloba58eb5117b3a254cf98cb45d3969d2de05d7c909
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides download to a given field defined in parameters.
5 * @package phpMyAdmin
6 */
8 /**
9 * Common functions.
11 require_once './libraries/common.inc.php';
12 require_once './libraries/mime.lib.php';
14 /* Check parameters */
15 PMA_checkParameters(array('db', 'table', 'where_clause', 'transform_key'));
17 /* Select database */
18 if (!PMA_DBI_select_db($db)) {
19 PMA_mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
20 '', '');
23 /* Check if table exists */
24 if (!PMA_DBI_get_columns($db, $table)) {
25 PMA_mysqlDie(__('Invalid table name'));
28 /* Grab data */
29 $sql = 'SELECT ' . PMA_backquote($transform_key) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
30 $result = PMA_DBI_fetch_value($sql);
32 /* Check return code */
33 if ($result === false) {
34 PMA_mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
37 /* Avoid corrupting data */
38 @ini_set('url_rewriter.tags', '');
40 header('Content-Type: ' . PMA_detectMIME($result));
41 header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
42 header('Content-Disposition: attachment; filename="' . $table . '-' . $transform_key . '.bin"');
43 if (PMA_USR_BROWSER_AGENT == 'IE') {
44 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
45 header('Pragma: public');
46 } else {
47 header('Pragma: no-cache');
48 // test case: exporting a database into a .gz file with Safari
49 // would produce files not having the current time
50 // (added this header for Safari but should not harm other browsers)
51 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
53 echo $result;