Translated using Weblate (French)
[phpmyadmin.git] / tbl_get_field.php
blobcc41376fa68d4fda8835885507d07a62449a249f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides download to a given field defined in parameters.
6 * @package PhpMyAdmin
7 */
9 /**
10 * Common functions.
12 // we don't want the usual PMA_Response-generated HTML above the column's data
13 define('PMA_BYPASS_GET_INSTANCE', 1);
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/mime.lib.php';
17 /**
18 * Sets globals from $_GET
20 $get_params = array(
21 'where_clause',
22 'transform_key'
25 foreach ($get_params as $one_get_param) {
26 if (isset($_GET[$one_get_param])) {
27 $GLOBALS[$one_get_param] = $_GET[$one_get_param];
31 /* Check parameters */
32 PMA_Util::checkParameters(
33 array('db', 'table', 'where_clause', 'transform_key')
36 /* Select database */
37 if (!PMA_DBI_select_db($db)) {
38 PMA_Util::mysqlDie(
39 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
40 '', ''
44 /* Check if table exists */
45 if (!PMA_DBI_get_columns($db, $table)) {
46 PMA_Util::mysqlDie(__('Invalid table name'));
49 /* Grab data */
50 $sql = 'SELECT ' . PMA_Util::backquote($transform_key)
51 . ' FROM ' . PMA_Util::backquote($table)
52 . ' WHERE ' . $where_clause . ';';
53 $result = PMA_DBI_fetch_value($sql);
55 /* Check return code */
56 if ($result === false) {
57 PMA_Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
60 /* Avoid corrupting data */
61 @ini_set('url_rewriter.tags', '');
63 PMA_downloadHeader(
64 $table . '-' . $transform_key . '.bin',
65 PMA_detectMIME($result),
66 strlen($result)
68 echo $result;