]> git.joonet.de Git - adminer.git/commitdiff
Allow limiting number of displayed rows in SQL command (bug #406)
authorJakub Vrana <jakub@vrana.cz>
Sat, 6 Dec 2014 19:11:34 +0000 (11:11 -0800)
committerJakub Vrana <jakub@vrana.cz>
Sat, 6 Dec 2014 19:12:51 +0000 (11:12 -0800)
adminer/include/editing.inc.php
adminer/include/version.inc.php
adminer/lang/cs.inc.php
adminer/lang/en.inc.php
adminer/lang/xx.inc.php
adminer/sql.inc.php
changes.txt

index e46ba47d755f896742fee0b7b4bbc49c93581794..dc5efabb510520c74b75f3ec9ec3dc41bc18e4c4 100644 (file)
@@ -3,9 +3,10 @@
 * @param Min_Result
 * @param Min_DB connection to examine indexes
 * @param array
+* @param int
 * @return array $orgtables
 */
-function select($result, $connection2 = null, $orgtables = array()) {
+function select($result, $connection2 = null, $orgtables = array(), $limit = 0) {
        global $jush;
        $links = array(); // colno => orgtable - create links from these columns
        $indexes = array(); // orgtable => array(column => colno) - primary keys
@@ -14,7 +15,7 @@ function select($result, $connection2 = null, $orgtables = array()) {
        $types = array(); // colno => type - display char in <code>
        $return = array(); // table => orgtable - mapping to use in EXPLAIN
        odd(''); // reset odd for each result
-       for ($i=0; $row = $result->fetch_row(); $i++) {
+       for ($i=0; (!$limit || $i < $limit) && ($row = $result->fetch_row()); $i++) {
                if (!$i) {
                        echo "<table cellspacing='0' class='nowrap'>\n";
                        echo "<thead><tr>";
index 730f98c65f410b497f0993192993b375c26bb02d..ba564aa77e1d60e0d4178cb78cd25dd116488f4c 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$VERSION = "4.1.1-dev";
+$VERSION = "4.2.0-dev";
index bb27bb58f9dc029913425154c4685f4144b8843a..49c452fd0ec4615ce586869ff4f6ce9069b14739 100644 (file)
@@ -235,11 +235,13 @@ $translations = array(
        'Sort' => 'Seřadit',
        'descending' => 'sestupně',
        'Limit' => 'Limit',
+       'Limit rows' => 'Limit řádek',
        'Text length' => 'Délka textů',
        'Action' => 'Akce',
        'Full table scan' => 'Průchod celé tabulky',
        'Unable to select the table' => 'Nepodařilo se vypsat tabulku',
        'No rows.' => 'Žádné řádky.',
+       '%d / ' => '%d / ',
        '%d row(s)' => array('%d řádek', '%d řádky', '%d řádků'),
        'Page' => 'Stránka',
        'last' => 'poslední',
index 52559f98019160e8c7c5c452c5c594adf3ed39e4..b4b3b57b27a25b6f833ed794b8873282f7c0c8da 100644 (file)
@@ -5,6 +5,7 @@ $translations = array(
        '%d byte(s)' => array('%d byte', '%d bytes'),
        'Routine has been called, %d row(s) affected.' => array('Routine has been called, %d row affected.', 'Routine has been called, %d rows affected.'),
        '%d process(es) have been killed.' => array('%d process has been killed.', '%d processes have been killed.'),
+       '%d / ' => '%d / ',
        '%d row(s)' => array('%d row', '%d rows'),
        '%d item(s) have been affected.' => array('%d item has been affected.', '%d items have been affected.'),
        '%d row(s) have been imported.' => array('%d row has been imported.', '%d rows have been imported.'),
index 5e5c15f733621e33abc011ca870fe6ab7165a5a7..fa3896b27f4f475fdca432be05a0eaffca30244f 100644 (file)
@@ -234,11 +234,13 @@ $translations = array(
        'Sort' => 'xx',
        'descending' => 'xx',
        'Limit' => 'xx',
+       'Limit rows' => 'xx',
        'Text length' => 'xx',
        'Action' => 'xx',
        'Full table scan' => 'xx',
        'Unable to select the table' => 'xx',
        'No rows.' => 'xx',
+       '%d / ' => 'xx',
        '%d row(s)' => array('xx', 'xx'),
        'Page' => 'xx',
        'last' => 'xx',
index 7f2e469503067436b2713eca28ac3d8b42de8be2..d1835f87a51ffc570d6f228fb26a772e425abb2b 100644 (file)
@@ -121,10 +121,13 @@ if (!$error && $_POST) {
                                                                }
 
                                                        } elseif (is_object($result)) {
-                                                               $orgtables = select($result, $connection2);
+                                                               $limit = $_POST["limit"];
+                                                               $orgtables = select($result, $connection2, array(), $limit);
                                                                if (!$_POST["only_errors"]) {
                                                                        echo "<form action='' method='post'>\n";
-                                                                       echo "<p>" . ($result->num_rows ? lang('%d row(s)', $result->num_rows) : "") . $time;
+                                                                       $num_rows = $result->num_rows;
+                                                                       echo "<p>" . ($num_rows ? ($limit && $num_rows > $limit ? lang('%d / ', $limit) : "") . lang('%d row(s)', $num_rows) : "");
+                                                                       echo $time;
                                                                        $id = "export-$commands";
                                                                        $export = ", <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('Export') . "</a><span id='$id' class='hidden'>: "
                                                                                . html_select("output", $adminer->dumpOutput(), $adminer_export["output"]) . " "
@@ -199,6 +202,7 @@ if (!isset($_GET["import"])) {
        textarea("query", $q, 20);
        echo ($_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n");
        echo "<p>$execute\n";
+       echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";
        
 } else {
        echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
index 37ac5e9ecda72b0fc3f89f40d92f56cec0cceb45..9d3abcea69eda35509633904d1b89bd6defbb204 100644 (file)
@@ -1,4 +1,5 @@
-Adminer 4.1.1-dev:
+Adminer 4.2.0-dev:
+Allow limiting number of displayed rows in SQL command
 Fix reading routine column collations
 Unlock session in alter database
 Make master key unreadable to others (bug #410)