}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return ($limit !== null ? " TOP (" . ($limit + $offset) . ")" : "") . " $query$where"; // seek later
+ return ($limit ? " TOP (" . ($limit + $offset) . ")" : "") . " $query$where"; // seek later
}
function limit1($table, $query, $where, $separator = "\n") {
* @param string $where including WHERE
*/
function limit(string $query, string $where, int $limit, int $offset = 0, string $separator = " "): string {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
/** Formulate SQL modification query with limit 1
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
return ($offset ? " * FROM (SELECT t.*, rownum AS rnum FROM (SELECT $query$where) t WHERE rownum <= " . ($limit + $offset) . ") WHERE rnum > $offset"
- : ($limit !== null ? " * FROM (SELECT $query$where) WHERE rownum <= " . ($limit + $offset)
+ : ($limit ? " * FROM (SELECT $query$where) WHERE rownum <= " . ($limit + $offset)
: " $query$where"
));
}
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function limit1($table, $query, $where, $separator = "\n") {
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function limit1($table, $query, $where, $separator = "\n") {
/** Print limit box in select */
function selectLimitPrint(int $limit): void {
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
- echo "<input type='number' name='limit' class='size' value='" . h($limit) . "'>";
+ echo "<input type='number' name='limit' class='size' value='" . intval($limit) . "'>";
echo script("qsl('input').oninput = selectFieldChange;", "");
echo "</div></fieldset>\n";
}
* @param int $page index of page starting at zero
* @return string empty string to use default query
*/
- function selectQueryBuild(array $select, array $where, array $group, array $order, ?int $limit, ?int $page): string {
+ function selectQueryBuild(array $select, array $where, array $group, array $order, int $limit, ?int $page): string {
return "";
}
* @param list<string> $where result of adminer()->selectSearchProcess()
* @param list<string> $group result of adminer()->selectColumnsProcess()[1]
* @param list<string> $order result of adminer()->selectOrderProcess()
- * @param int|numeric-string $limit result of adminer()->selectLimitProcess()
+ * @param int $limit result of adminer()->selectLimitProcess()
* @param int $page index of page starting at zero
* @param bool $print whether to print the query
* @return Result|false
*/
- function select(string $table, array $select, array $where, array $group, array $order = array(), $limit = 1, ?int $page = 0, bool $print = false) {
+ function select(string $table, array $select, array $where, array $group, array $order = array(), int $limit = 1, ?int $page = 0, bool $print = false) {
$is_group = (count($group) < count($select));
$query = adminer()->selectQueryBuild($select, $where, $group, $order, $limit, $page);
if (!$query) {
$query = "SELECT" . limit(
- ($_GET["page"] != "last" && $limit != "" && $group && $is_group && JUSH == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . implode(", ", $select) . "\nFROM " . table($table),
+ ($_GET["page"] != "last" && $limit && $group && $is_group && JUSH == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . implode(", ", $select) . "\nFROM " . table($table),
($where ? "\nWHERE " . implode(" AND ", $where) : "") . ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""),
- ($limit != "" ? +$limit : null),
+ $limit,
($page ? $limit * $page : 0),
"\n"
);
$page = $_GET["page"];
if ($page == "last") {
$found_rows = get_val(count_rows($TABLE, $where, $is_group, $group));
- $page = floor(max(0, intval($found_rows) - 1) / intval($limit));
+ $page = floor(max(0, intval($found_rows) - 1) / $limit);
}
$select2 = $select;
}
// use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
- if ($_GET["page"] != "last" && $limit != "" && $group && $is_group && JUSH == "sql") {
+ if ($_GET["page"] != "last" && $limit && $group && $is_group && JUSH == "sql") {
$found_rows = get_val(" SELECT FOUND_ROWS()"); // space to allow mysql.trace_mode
}
$exact_count = true;
$found_rows = null;
if ($_GET["page"] != "last") {
- if ($limit == "" || (count($rows) < $limit && ($rows || !$page))) {
+ if (!$limit || (count($rows) < $limit && ($rows || !$page))) {
$found_rows = ($page ? $page * $limit : 0) + count($rows);
} elseif (JUSH != "sql" || !$is_group) {
$found_rows = ($is_group ? false : found_rows($table_status, $where));
- if (intval($found_rows) < max(1e4, 2 * ($page + 1) * intval($limit))) {
+ if (intval($found_rows) < max(1e4, 2 * ($page + 1) * $limit)) {
// slow with big tables
$found_rows = first(slow_query(count_rows($TABLE, $where, $is_group, $group)));
} else {
}
}
- $pagination = ($limit != "" && ($found_rows === false || $found_rows > $limit || $page));
+ $pagination = ($limit && ($found_rows === false || $found_rows > $limit || $page));
if ($pagination) {
echo (($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit
? '<p><a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" class="loadmore">' . lang('Load more data') . '</a>'
- . script("qsl('a').onclick = partial(selectLoadMore, " . intval($limit) . ", '" . lang('Loading') . "…');", "")
+ . script("qsl('a').onclick = partial(selectLoadMore, $limit, '" . lang('Loading') . "…');", "")
: ''
);
echo "\n";
// display first, previous 4, next 4 and last page
$max_page = ($found_rows === false
? $page + (count($rows) >= $limit ? 2 : 1)
- : floor(($found_rows - 1) / intval($limit))
+ : floor(($found_rows - 1) / $limit)
);
echo "<fieldset>";
if (JUSH != "simpledb") {
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? ", $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? ", $offset" : "") : "");
}
function limit1($table, $query, $where, $separator = "\n") {
}
if ($limit) {
- $data["size"] = +$limit;
+ $data["size"] = $limit;
if ($page) {
$data["from"] = ($page * $limit);
}
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function collations() {
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
$return = '';
- $return .= ($limit !== null ? $separator . "FIRST $limit" . ($offset ? " SKIP $offset" : "") : "");
+ $return .= ($limit ? $separator . "FIRST $limit" . ($offset ? " SKIP $offset" : "") : "");
$return .= " $query$where";
return $return;
}
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function idf_escape($idf) {
$val = preg_replace('~ DESC$~', '', $val, 1, $count);
$sort[$val] = ($count ? -1 : 1);
}
- if (isset($_GET['limit']) && is_numeric($_GET['limit']) && $_GET['limit'] > 0) {
- $limit = $_GET['limit'];
- }
- $limit = min(200, max(1, (int) $limit));
+ $limit = min(200, max(1, $limit));
$skip = $page * $limit;
try {
return new Result($this->conn->_link->executeQuery($this->conn->_db_name . ".$table", new \MongoDB\Driver\Query($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort))));
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
- return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" : "");
+ return " $query$where" . ($limit ? $separator . "LIMIT $limit" : "");
}
function unconvert_field($field, $return) {