2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides download to a given field defined in parameters.
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(
23 if (!$GLOBALS['dbi']->selectDb($db)) {
25 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
30 /* Check if table exists */
31 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
32 PMA_Util
::mysqlDie(__('Invalid table name'));
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', '');
50 $table . '-' . $_GET['transform_key'] . '.bin',
51 PMA_detectMIME($result),
52 /*overload*/mb_strlen($result, '8bit')