Translated using Weblate (Tatar)
[phpmyadmin.git] / tbl_get_field.php
blobada209f46eeb56b34244b6f6a79c26e6ba0753e3
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 require_once 'libraries/common.inc.php';
13 require_once 'libraries/mime.lib.php';
15 /**
16 * Sets globals from $_GET
18 $get_params = array(
19 'where_clause',
20 'transform_key'
23 foreach ($get_params as $one_get_param) {
24 if (isset($_GET[$one_get_param])) {
25 $GLOBALS[$one_get_param] = $_GET[$one_get_param];
29 /* Check parameters */
30 PMA_Util::checkParameters(
31 array('db', 'table', 'where_clause', 'transform_key')
34 /* Select database */
35 if (!PMA_DBI_select_db($db)) {
36 PMA_Util::mysqlDie(
37 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
38 '', ''
42 /* Check if table exists */
43 if (!PMA_DBI_get_columns($db, $table)) {
44 PMA_Util::mysqlDie(__('Invalid table name'));
47 /* Grab data */
48 $sql = 'SELECT ' . PMA_Util::backquote($transform_key)
49 . ' FROM ' . PMA_Util::backquote($table)
50 . ' WHERE ' . $where_clause . ';';
51 $result = PMA_DBI_fetch_value($sql);
53 /* Check return code */
54 if ($result === false) {
55 PMA_Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
58 /* Avoid corrupting data */
59 @ini_set('url_rewriter.tags', '');
61 PMA_downloadHeader(
62 $table . '-' . $transform_key . '.bin',
63 PMA_detectMIME($result),
64 strlen($result)
66 echo $result;