本文整理汇总了PHP中BigTree::nextSQLColumnDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::nextSQLColumnDefinition方法的具体用法?PHP BigTree::nextSQLColumnDefinition怎么用?PHP BigTree::nextSQLColumnDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::nextSQLColumnDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearchResults
static function getSearchResults($view, $page = 1, $query = "", $sort = "id DESC", $group = false)
{
// Check to see if we've cached this table before.
self::cacheViewData($view);
$search_parts = explode(" ", strtolower($query));
$view_columns = count($view["fields"]);
if ($group !== false) {
$query = "SELECT * FROM bigtree_module_view_cache WHERE view = '" . $view["id"] . "' AND group_field = '" . sqlescape($group) . "'" . self::getFilterQuery($view);
} else {
$query = "SELECT * FROM bigtree_module_view_cache WHERE view = '" . $view["id"] . "'" . self::getFilterQuery($view);
}
foreach ($search_parts as $part) {
$x = 0;
$qp = array();
$part = sqlescape(strtolower($part));
while ($x < $view_columns) {
$x++;
$qp[] = "column{$x} LIKE '%{$part}%'";
}
if (count($qp)) {
$query .= " AND (" . implode(" OR ", $qp) . ")";
}
}
$per_page = $view["options"]["per_page"] ? $view["options"]["per_page"] : BigTreeAdmin::$PerPage;
$pages = ceil(sqlrows(sqlquery($query)) / $per_page);
$pages = $pages > 0 ? $pages : 1;
$results = array();
// Get the correct column name for sorting
if (strpos($sort, "`") !== false) {
// New formatting
$sort_field = BigTree::nextSQLColumnDefinition(substr($sort, 1));
$sort_pieces = explode(" ", $sort);
$sort_direction = end($sort_pieces);
} else {
// Old formatting
list($sort_field, $sort_direction) = explode(" ", $sort);
}
if ($sort_field != "id") {
$x = 0;
if (isset($view["fields"][$sort_field]["numeric"]) && $view["fields"][$sort_field]["numeric"]) {
$convert_numeric = true;
} else {
$convert_numeric = false;
}
foreach ($view["fields"] as $field => $options) {
$x++;
if ($field == $sort_field) {
$sort_field = "column{$x}";
}
}
// If we didn't find a column, let's assume it's the default sort field.
if (substr($sort_field, 0, 6) != "column") {
$sort_field = "sort_field";
}
if ($convert_numeric) {
$sort_field = "CONVERT(" . $sort_field . ",SIGNED)";
}
} else {
$sort_field = "CONVERT(id,UNSIGNED)";
}
if (strtolower($sort) == "position desc, id asc") {
$sort_field = "position DESC, id ASC";
$sort_direction = "";
} else {
$sort_direction = strtolower($sort_direction) == "asc" ? "ASC" : "DESC";
}
if ($page === "all") {
$q = sqlquery($query . " ORDER BY {$sort_field} {$sort_direction}");
} else {
$q = sqlquery($query . " ORDER BY {$sort_field} {$sort_direction} LIMIT " . ($page - 1) * $per_page . ",{$per_page}");
}
while ($f = sqlfetch($q)) {
unset($f["hash"]);
$results[] = $f;
}
return array("pages" => $pages, "results" => $results);
}
示例2: elseif
BigTree::globalizeArray($bigtree["view"]);
$m = BigTreeAutoModule::getModuleForView($bigtree["view"]);
$perm = $admin->checkAccess($m);
if (isset($_GET["sort"])) {
$sort = $_GET["sort"] . " " . $_GET["sort_direction"];
} elseif (isset($options["sort_column"])) {
$sort = $options["sort_column"] . " " . $options["sort_direction"];
} elseif (isset($options["sort"])) {
$sort = $options["sort"];
} else {
$sort = "id DESC";
}
// Retrieve the column and the sort direction from the consolidated ORDER BY statement.
$sort = ltrim($sort, "`");
$sort_column = BigTree::nextSQLColumnDefinition($sort);
$sort_pieces = explode(" ", $sort);
$sort_direction = end($sort_pieces);
// See if we're searching for anything.
$search = isset($_GET["search"]) ? $_GET["search"] : "";
?>
<div class="table auto_modules">
<summary>
<input type="search" class="form_search" id="search" placeholder="Search" value="<?php
echo htmlspecialchars($search);
?>
" />
<span class="form_search_icon"></span>
<nav id="view_paging" class="view_paging"></nav>
</summary>
<header>