Translated using Weblate (Kazakh)
[phpmyadmin.git] / tbl_get_field.php
blob975102790bb8b23cccbf94853bb98dfee5b9eb62
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;
10 use PhpMyAdmin\Mime;
11 use PhpMyAdmin\Response;
13 /**
14 * Common functions.
16 require_once 'libraries/common.inc.php';
18 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
19 // data
20 $response = Response::getInstance();
21 $response->disable();
23 /* Check parameters */
24 PhpMyAdmin\Util::checkParameters(
25 array('db', 'table')
28 /* Select database */
29 if (!$GLOBALS['dbi']->selectDb($db)) {
30 PhpMyAdmin\Util::mysqlDie(
31 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
32 '', false
36 /* Check if table exists */
37 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
38 PhpMyAdmin\Util::mysqlDie(__('Invalid table name'));
41 /* Grab data */
42 $sql = 'SELECT ' . PhpMyAdmin\Util::backquote($_GET['transform_key'])
43 . ' FROM ' . PhpMyAdmin\Util::backquote($table)
44 . ' WHERE ' . $_GET['where_clause'] . ';';
45 $result = $GLOBALS['dbi']->fetchValue($sql);
47 /* Check return code */
48 if ($result === false) {
49 PhpMyAdmin\Util::mysqlDie(
50 __('MySQL returned an empty result set (i.e. zero rows).'), $sql
54 /* Avoid corrupting data */
55 ini_set('url_rewriter.tags', '');
57 Core::downloadHeader(
58 $table . '-' . $_GET['transform_key'] . '.bin',
59 Mime::detect($result),
60 strlen($result)
62 echo $result;