~ubuntu-branches/ubuntu/utopic/phpmyadmin/utopic

« back to all changes in this revision

Viewing changes to libraries/TableSearch.class.php

  • Committer: Package Import Robot
  • Author(s): Michal Čihař
  • Date: 2014-05-10 16:31:42 UTC
  • mfrom: (1.2.55)
  • Revision ID: package-import@ubuntu.com-20140510163142-z03w5qirp4nnfoiy
Tags: 4:4.2.0-1
* New upstream release.
* Upgrade database for current phpMyAdmin configuration storage and
  in the configuration (Closes: #746956).

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
        $html_output = '';
270
270
        if (is_array($foreignData['disp_row'])) {
271
271
            $html_output .=  '<select name="criteriaValues[' . $column_index . ']"'
272
 
                . ' id="' . $column_id . $column_index .'">';
 
272
                . ' id="' . $column_id . $column_index . '">';
273
273
            $html_output .= PMA_foreignDropdown(
274
274
                $foreignData['disp_row'], $foreignData['foreign_field'],
275
275
                $foreignData['foreign_display'], '', $foreignMaxLimit
280
280
            $html_output .= '<input type="text" id="' . $column_id
281
281
                . $column_index . '"'
282
282
                . ' name="criteriaValues[' . $column_index . ']" id="field_'
283
 
                . md5($column_name) . '[' . $column_index .']" class="textfield"'
 
283
                . md5($column_name) . '[' . $column_index . ']" class="textfield"'
284
284
                . (isset($criteriaValues[$column_index])
285
285
                    && is_string($criteriaValues[$column_index])
286
286
                    ? (' value="' . $criteriaValues[$column_index] . '"')
334
334
            || (strncasecmp($column_type, 'set', 3) && $in_zoom_search_edit)
335
335
        ) {
336
336
            $html_output .= '<select name="criteriaValues[' . ($column_index)
337
 
                . ']" id="' . $column_id . $column_index .'">';
 
337
                . ']" id="' . $column_id . $column_index . '">';
338
338
        } else {
339
339
            $html_output .= '<select name="criteriaValues[' . $column_index . ']"'
340
340
                . ' id="' . $column_id . $column_index . '" multiple="multiple"'
418
418
            }
419
419
 
420
420
            $str .= '<input type="text" name="criteriaValues[' . $column_index . ']"'
421
 
                .' size="40" class="' . $the_class . '" id="'
 
421
                . ' size="40" class="' . $the_class . '" id="'
422
422
                . $column_id . $column_index . '"'
423
423
                . (isset($criteriaValues[$column_index])
424
424
                    && is_string($criteriaValues[$column_index])
549
549
        $backquoted_name = PMA_Util::backquote($names);
550
550
        $where = '';
551
551
        if ($unaryFlag) {
552
 
            $criteriaValues = '';
553
552
            $where = $backquoted_name . ' ' . $func_type;
554
553
 
555
554
        } elseif (strncasecmp($types, 'enum', 4) == 0 && ! empty($criteriaValues)) {
579
578
                $criteriaValues = '^' . $criteriaValues . '$';
580
579
            }
581
580
 
582
 
            if ('IN (...)' == $func_type
583
 
                || 'NOT IN (...)' == $func_type
584
 
                || 'BETWEEN' == $func_type
585
 
                || 'NOT BETWEEN' == $func_type
 
581
            if ('IN (...)' != $func_type
 
582
                && 'NOT IN (...)' != $func_type
 
583
                && 'BETWEEN' != $func_type
 
584
                && 'NOT BETWEEN' != $func_type
586
585
            ) {
587
 
                $func_type = str_replace(' (...)', '', $func_type);
588
 
 
589
 
                //Don't explode if this is already an array
590
 
                //(Case for (NOT) IN/BETWEEN.)
591
 
                if (is_array($criteriaValues)) {
592
 
                    $values = $criteriaValues;
593
 
                } else {
594
 
                    $values = explode(',', $criteriaValues);
595
 
                }
596
 
                // quote values one by one
597
 
                $emptyKey = false;
598
 
                foreach ($values as $key => &$value) {
599
 
                    if ('' === $value) {
600
 
                        $emptyKey = $key;
601
 
                        $value = 'NULL';
602
 
                        continue;
603
 
                    }
604
 
                    $value = $quot . PMA_Util::sqlAddSlashes(trim($value))
605
 
                        . $quot;
606
 
                }
607
 
 
608
 
                if ('BETWEEN' == $func_type || 'NOT BETWEEN' == $func_type) {
609
 
                    $where = $backquoted_name . ' ' . $func_type . ' '
610
 
                        . (isset($values[0]) ? $values[0] : '')
611
 
                        . ' AND ' . (isset($values[1]) ? $values[1] : '');
612
 
                } else { //[NOT] IN
613
 
                    if (false !== $emptyKey) {
614
 
                        unset($values[$emptyKey]);
615
 
                    }
616
 
                    $wheres = array();
617
 
                    if (!empty($values)) {
618
 
                        $wheres[] = $backquoted_name . ' ' . $func_type
619
 
                            . ' (' . implode(',', $values) . ')';
620
 
                    }
621
 
                    if (false !== $emptyKey) {
622
 
                        $wheres[] = $backquoted_name . ' IS NULL';
623
 
                    }
624
 
                    $where = implode(' OR ', $wheres);
625
 
                    if (1 < count($wheres)) {
626
 
                        $where = '(' . $where . ')';
627
 
                    }
628
 
                }
629
 
            } else {
630
586
                if ($func_type == 'LIKE %...%' || $func_type == 'LIKE') {
631
587
                    $where = $backquoted_name . ' ' . $func_type . ' ' . $quot
632
588
                        . PMA_Util::sqlAddSlashes($criteriaValues, true) . $quot;
634
590
                    $where = $backquoted_name . ' ' . $func_type . ' ' . $quot
635
591
                        . PMA_Util::sqlAddSlashes($criteriaValues) . $quot;
636
592
                }
 
593
                return $where;
 
594
            }
 
595
            $func_type = str_replace(' (...)', '', $func_type);
 
596
 
 
597
            //Don't explode if this is already an array
 
598
            //(Case for (NOT) IN/BETWEEN.)
 
599
            if (is_array($criteriaValues)) {
 
600
                $values = $criteriaValues;
 
601
            } else {
 
602
                $values = explode(',', $criteriaValues);
 
603
            }
 
604
            // quote values one by one
 
605
            $emptyKey = false;
 
606
            foreach ($values as $key => &$value) {
 
607
                if ('' === $value) {
 
608
                    $emptyKey = $key;
 
609
                    $value = 'NULL';
 
610
                    continue;
 
611
                }
 
612
                $value = $quot . PMA_Util::sqlAddSlashes(trim($value))
 
613
                    . $quot;
 
614
            }
 
615
 
 
616
            if ('BETWEEN' == $func_type || 'NOT BETWEEN' == $func_type) {
 
617
                $where = $backquoted_name . ' ' . $func_type . ' '
 
618
                    . (isset($values[0]) ? $values[0] : '')
 
619
                    . ' AND ' . (isset($values[1]) ? $values[1] : '');
 
620
            } else { //[NOT] IN
 
621
                if (false !== $emptyKey) {
 
622
                    unset($values[$emptyKey]);
 
623
                }
 
624
                $wheres = array();
 
625
                if (!empty($values)) {
 
626
                    $wheres[] = $backquoted_name . ' ' . $func_type
 
627
                        . ' (' . implode(',', $values) . ')';
 
628
                }
 
629
                if (false !== $emptyKey) {
 
630
                    $wheres[] = $backquoted_name . ' IS NULL';
 
631
                }
 
632
                $where = implode(' OR ', $wheres);
 
633
                if (1 < count($wheres)) {
 
634
                    $where = '(' . $where . ')';
 
635
                }
637
636
            }
638
637
        } // end if
639
638
 
879
878
            . __("Use this column to label each point") . '</label></td>';
880
879
        $html_output .= '<td><select name="dataLabel" id="dataLabel" >'
881
880
            . '<option value = "">' . __('None') . '</option>';
882
 
        for ($j = 0; $j < count($this->_columnNames); $j++) {
 
881
        for ($j = 0, $nb = count($this->_columnNames); $j < $nb; $j++) {
883
882
            if (isset($dataLabel)
884
883
                && $dataLabel == htmlspecialchars($this->_columnNames[$j])
885
884
            ) {
970
969
        $html_output = '';
971
970
        // for every column present in table
972
971
        for (
973
 
            $column_index = 0;
974
 
            $column_index < count($this->_columnNames);
 
972
            $column_index = 0, $nb = count($this->_columnNames);
 
973
            $column_index < $nb;
975
974
            $column_index++
976
975
        ) {
977
976
            $html_output .= '<tr class="noclick '
1039
1038
                . 'tableid_' . $i . '" >';
1040
1039
            $html_output .= '<option value="' . 'pma_null' . '">' . __('None')
1041
1040
                . '</option>';
1042
 
            for ($j = 0 ; $j < count($this->_columnNames); $j++) {
 
1041
            for ($j = 0, $nb = count($this->_columnNames); $j < $nb; $j++) {
1043
1042
                if (isset($_POST['criteriaColumnNames'][$i])
1044
1043
                    && $_POST['criteriaColumnNames'][$i] == htmlspecialchars($this->_columnNames[$j])
1045
1044
                ) {
1288
1287
        $html_output .= '<tbody>';
1289
1288
        $odd_row = true;
1290
1289
        for (
1291
 
            $column_index = 0;
1292
 
            $column_index < count($this->_columnNames);
 
1290
            $column_index = 0, $nb = count($this->_columnNames);
 
1291
            $column_index < $nb;
1293
1292
            $column_index++
1294
1293
        ) {
1295
1294
            $fieldpopup = $this->_columnNames[$column_index];
1344
1343
            . '<input type="text" value="" name="replaceWith" required />';
1345
1344
 
1346
1345
        $htmlOutput .= __('Column:') . '<select name="columnIndex">';
1347
 
        for ($i = 0; $i < count($this->_columnNames); $i++) {
 
1346
        for ($i = 0, $nb = count($this->_columnNames); $i < $nb; $i++) {
1348
1347
            $type = preg_replace('@\(.*@s', '', $this->_columnTypes[$i]);
1349
1348
            if ($GLOBALS['PMA_Types']->getTypeClass($type) == 'CHAR') {
1350
1349
                $column = $this->_columnNames[$i];
1384
1383
        $sql_query .= " GROUP BY " . PMA_Util::backquote($column)
1385
1384
            . " ORDER BY " . PMA_Util::backquote($column) . " ASC";
1386
1385
 
1387
 
        $rs = $GLOBALS['dbi']->query(
 
1386
        $resultSet = $GLOBALS['dbi']->query(
1388
1387
            $sql_query, null, PMA_DatabaseInterface::QUERY_STORE
1389
1388
        );
1390
1389
 
1411
1410
 
1412
1411
        $htmlOutput .= '<tbody>';
1413
1412
        $odd = true;
1414
 
        while ($row = $GLOBALS['dbi']->fetchRow($rs)) {
 
1413
        while ($row = $GLOBALS['dbi']->fetchRow($resultSet)) {
1415
1414
            $val = $row[0];
1416
1415
            $replaced = $row[1];
1417
1416
            $count = $row[2];