Translated using Weblate (Urdu)
[phpmyadmin.git] / tbl_get_field.php
blob060b28e4cca77a8e29a534749e9b47f3197e7aba
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 /**
10 * Common functions.
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(
19 array('db', 'table')
22 /* Select database */
23 if (!$GLOBALS['dbi']->selectDb($db)) {
24 PMA_Util::mysqlDie(
25 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
26 '', ''
30 /* Check if table exists */
31 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
32 PMA_Util::mysqlDie(__('Invalid table name'));
35 /* Grab data */
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', '');
49 PMA_downloadHeader(
50 $table . '-' . $_GET['transform_key'] . '.bin',
51 PMA_detectMIME($result),
52 strlen($result)
54 echo $result;