Translated using Weblate (Korean)
[phpmyadmin.git] / tbl_get_field.php
blob366dd683e5a92adad0995d7ccf1485163b917fa4
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 use PhpMyAdmin\Core;
11 /**
12 * Common functions.
14 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
15 // data
16 define('PMA_BYPASS_GET_INSTANCE', 1);
17 require_once 'libraries/common.inc.php';
18 require_once 'libraries/mime.lib.php';
20 /* Check parameters */
21 PhpMyAdmin\Util::checkParameters(
22 array('db', 'table')
25 /* Select database */
26 if (!$GLOBALS['dbi']->selectDb($db)) {
27 PhpMyAdmin\Util::mysqlDie(
28 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
29 '', false
33 /* Check if table exists */
34 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
35 PhpMyAdmin\Util::mysqlDie(__('Invalid table name'));
38 /* Grab data */
39 $sql = 'SELECT ' . PhpMyAdmin\Util::backquote($_GET['transform_key'])
40 . ' FROM ' . PhpMyAdmin\Util::backquote($table)
41 . ' WHERE ' . $_GET['where_clause'] . ';';
42 $result = $GLOBALS['dbi']->fetchValue($sql);
44 /* Check return code */
45 if ($result === false) {
46 PhpMyAdmin\Util::mysqlDie(
47 __('MySQL returned an empty result set (i.e. zero rows).'), $sql
51 /* Avoid corrupting data */
52 @ini_set('url_rewriter.tags', '');
54 Core::downloadHeader(
55 $table . '-' . $_GET['transform_key'] . '.bin',
56 PMA_detectMIME($result),
57 strlen($result)
59 echo $result;