//Set default datalabel if not selected
if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
    $dataLabel = PMA_getDisplayField($db, $table);
} else {
    $dataLabel = $_POST['dataLabel'];
}
// Displays the zoom search form
$response->addHTML($table_search->getSecondaryTabs());
$response->addHTML($table_search->getSelectionForm($goto, $dataLabel));
/*
 * Handle the input criteria and generate the query result
 * Form for displaying query results
 */
if (isset($_POST['zoom_submit']) && $_POST['criteriaColumnNames'][0] != 'pma_null' && $_POST['criteriaColumnNames'][1] != 'pma_null' && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]) {
    //Query generation part
    $sql_query = $table_search->buildSqlQuery();
    $sql_query .= ' LIMIT ' . $_POST['maxPlotLimit'];
    //Query execution part
    $result = $GLOBALS['dbi']->query($sql_query . ";", null, PMA_DatabaseInterface::QUERY_STORE);
    $fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
    $data = array();
    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
        //Need a row with indexes as 0,1,2 for the getUniqueCondition
        // hence using a temporary array
        $tmpRow = array();
        foreach ($row as $val) {
            $tmpRow[] = $val;
        }
        //Get unique condition on each row (will be needed for row update)
        $uniqueCondition = PMA_Util::getUniqueCondition($result, count($table_search->getColumnNames()), $fields_meta, $tmpRow, true);
        //Append it to row array as where_clause
Пример #2
0
 /**
  * Test for buildSqlQuery
  *
  * @return void
  */
 public function testBuildSqlQueryw()
 {
     $_POST['distinct'] = true;
     $_POST['zoom_submit'] = true;
     $_POST['table'] = "PMA";
     $_POST['orderByColumn'] = "name";
     $_POST['order'] = "asc";
     $_POST['customWhereClause'] = "name='pma'";
     $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom");
     $sql = $tableSearch->buildSqlQuery();
     $result = "SELECT DISTINCT *  FROM `PMA` WHERE name='pma' " . "ORDER BY `name` asc";
     $this->assertEquals($result, $sql);
     unset($_POST['customWhereClause']);
     $sql = $tableSearch->buildSqlQuery();
     $result = "SELECT DISTINCT *  FROM `PMA` ORDER BY `name` asc";
     $this->assertEquals($result, $sql);
     $_POST['criteriaValues'] = array('value1', 'value2', 'value3', 'value4', 'value5', 'value6', 'value7,value8');
     $_POST['criteriaColumnNames'] = array('name', 'id', 'index', 'index2', 'index3', 'index4', 'index5');
     $_POST['criteriaColumnTypes'] = array('varchar', 'int', 'enum', 'type1', 'type2', 'type3', 'type4');
     $_POST['criteriaColumnCollations'] = array("char1", "char2", "char3", "char4", "char5", "char6", "char7");
     $_POST['criteriaColumnOperators'] = array("!=", ">", "IS NULL", "LIKE %...%", "REGEXP ^...\$", "IN (...)", "BETWEEN");
     $sql = $tableSearch->buildSqlQuery();
     $result = "SELECT DISTINCT *  FROM `PMA` WHERE `name` != 'value1'" . " AND `id` > value2 AND `index` IS NULL AND `index2` LIKE '%value4%'" . " AND `index3` REGEXP ^value5\$ AND `index4` IN (value6) AND `index5`" . " BETWEEN value7 AND value8 ORDER BY `name` asc";
     $this->assertEquals($result, $sql);
 }