2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides download to a given field defined in parameters.
8 declare(strict_types
=1);
12 use PhpMyAdmin\Response
;
17 require_once 'libraries/common.inc.php';
19 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
21 $response = Response
::getInstance();
24 /* Check parameters */
25 PhpMyAdmin\Util
::checkParameters(
30 if (!$GLOBALS['dbi']->selectDb($db)) {
31 PhpMyAdmin\Util
::mysqlDie(
32 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
38 /* Check if table exists */
39 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
40 PhpMyAdmin\Util
::mysqlDie(__('Invalid table name'));
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).'),
57 /* Avoid corrupting data */
58 ini_set('url_rewriter.tags', '');
61 $table . '-' . $_GET['transform_key'] . '.bin',
62 Mime
::detect($result),