Exemplo n.º 1
0
/**
 * Function to send html for column dropdown list
 *
 * @return void
 */
function PMA_sendHtmlForColumnDropdownList()
{
    $response = PMA_Response::getInstance();
    $foreignTable = $_REQUEST['foreignTable'];
    $table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
    // Since views do not have keys defined on them provide the full list of columns
    if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
        $columnList = $table_obj->getColumns(false, false);
    } else {
        $columnList = $table_obj->getIndexedColumns(false, false);
    }
    $columns = array();
    foreach ($columnList as $column) {
        $columns[] = htmlspecialchars($column);
    }
    $response->addJSON('columns', $columns);
    // @todo should be: $server->db($db)->table($table)->primary()
    $primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
    if (false === $primary) {
        return;
    }
    $primarycols = array_keys($primary->getColumns());
    $response->addJSON('primary', $primarycols);
}
Exemplo n.º 2
0
 /**
  * Test for getColumns
  *
  * @return void
  */
 public function testGetColumns()
 {
     $table = 'PMA_BookMark';
     $db = 'PMA';
     $table = new PMA_Table($table, $db);
     $return = $table->getColumns();
     $expect = array('`PMA`.`PMA_BookMark`.`column1`', '`PMA`.`PMA_BookMark`.`column3`', '`PMA`.`PMA_BookMark`.`column5`', '`PMA`.`PMA_BookMark`.`ACCESSIBLE`', '`PMA`.`PMA_BookMark`.`ADD`', '`PMA`.`PMA_BookMark`.`ALL`');
     $this->assertEquals($expect, $return);
     $return = $table->getReservedColumnNames();
     $expect = array('ACCESSIBLE', 'ADD', 'ALL');
     $this->assertEquals($expect, $return);
 }
Exemplo n.º 3
0
require_once 'libraries/common.inc.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/structure.lib.php';
$response = PMA_Response::getInstance();
// Send table of column names to populate corresponding dropdowns depending
// on the current selection
if (isset($_REQUEST['getDropdownValues']) && $_REQUEST['getDropdownValues'] === 'true') {
    if (isset($_REQUEST['foreignTable'])) {
        // if both db and table are selected
        $foreignTable = $_REQUEST['foreignTable'];
        $table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
        // Since views do not have keys defined on them provide the full list of columns
        if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
            $columnList = $table_obj->getColumns(false, false);
        } else {
            $columnList = $table_obj->getIndexedColumns(false, false);
        }
        $columns = array();
        foreach ($columnList as $column) {
            $columns[] = htmlspecialchars($column);
        }
        $response->addJSON('columns', $columns);
        // @todo should be: $server->db($db)->table($table)->primary()
        $primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
        if (false === $primary) {
            return;
        }
        $primarycols = array_keys($primary->getColumns());
        $response->addJSON('primary', $primarycols);