Translated using Weblate (French)
[phpmyadmin.git] / tbl_get_field.php
blob110873a490e5f3c7404a52274b399c194ce85a52
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 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Mime;
12 use PhpMyAdmin\Response;
14 /**
15 * Common functions.
17 require_once 'libraries/common.inc.php';
19 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
20 // data
21 $response = Response::getInstance();
22 $response->disable();
24 /* Check parameters */
25 PhpMyAdmin\Util::checkParameters(
26 ['db', 'table']
29 /* Select database */
30 if (!$GLOBALS['dbi']->selectDb($db)) {
31 PhpMyAdmin\Util::mysqlDie(
32 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
33 '',
34 false
38 /* Check if table exists */
39 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
40 PhpMyAdmin\Util::mysqlDie(__('Invalid table name'));
43 /* Grab data */
44 $sql = 'SELECT ' . PhpMyAdmin\Util::backquote($_GET['transform_key'])
45 . ' FROM ' . PhpMyAdmin\Util::backquote($table)
46 . ' WHERE ' . $_GET['where_clause'] . ';';
47 $result = $GLOBALS['dbi']->fetchValue($sql);
49 /* Check return code */
50 if ($result === false) {
51 PhpMyAdmin\Util::mysqlDie(
52 __('MySQL returned an empty result set (i.e. zero rows).'),
53 $sql
57 /* Avoid corrupting data */
58 ini_set('url_rewriter.tags', '');
60 Core::downloadHeader(
61 $table . '-' . $_GET['transform_key'] . '.bin',
62 Mime::detect($result),
63 strlen($result)
65 echo $result;