Translated using Weblate (Italian)
[phpmyadmin.git] / tbl_get_field.php
blobf4570ebac12c86d59c11cff7bfdd74c1110b96bd
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 /* Check parameters */
18 PMA_Util::checkParameters(
19 array('db', 'table')
22 /* Select database */
23 if (!$GLOBALS['dbi']->selectDb($db)) {
24 PMA_Util::mysqlDie(
25 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
26 '', false
30 /* Check if table exists */
31 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
32 PMA_Util::mysqlDie(__('Invalid table name'));
35 /* Grab data */
36 $sql = 'SELECT ' . PMA_Util::backquote($_GET['transform_key'])
37 . ' FROM ' . PMA_Util::backquote($table)
38 . ' WHERE ' . $_GET['where_clause'] . ';';
39 $result = $GLOBALS['dbi']->fetchValue($sql);
41 /* Check return code */
42 if ($result === false) {
43 PMA_Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
46 /* Avoid corrupting data */
47 @ini_set('url_rewriter.tags', '');
49 PMA_downloadHeader(
50 $table . '-' . $_GET['transform_key'] . '.bin',
51 PMA_detectMIME($result),
52 /*overload*/mb_strlen($result, '8bit')
54 echo $result;