Merge branch 'master' of ssh://repo.or.cz/srv/git/phpmyadmin/madhuracj into OpenGIS
[phpmyadmin/madhuracj.git] / tbl_get_field.php
blob5c7d0171c8b079131cc15bd82c2cb9a103ac19a0
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides download to a given field defined in parameters.
5 * @package PhpMyAdmin
6 */
8 /**
9 * Common functions.
11 require_once './libraries/common.inc.php';
12 require_once './libraries/mime.lib.php';
14 /* Check parameters */
15 PMA_checkParameters(array('db', 'table', 'where_clause', 'transform_key'));
17 /* Select database */
18 if (!PMA_DBI_select_db($db)) {
19 PMA_mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
20 '', '');
23 /* Check if table exists */
24 if (!PMA_DBI_get_columns($db, $table)) {
25 PMA_mysqlDie(__('Invalid table name'));
28 /* Grab data */
29 $sql = 'SELECT ' . PMA_backquote($transform_key) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
30 $result = PMA_DBI_fetch_value($sql);
32 /* Check return code */
33 if ($result === false) {
34 PMA_mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
37 /* Avoid corrupting data */
38 @ini_set('url_rewriter.tags', '');
40 PMA_download_header(
41 $table . '-' . $transform_key . '.bin',
42 PMA_detectMIME($result),
43 strlen($result)
45 echo $result;