本文整理汇总了PHP中SQLSelect::AddOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLSelect::AddOrder方法的具体用法?PHP SQLSelect::AddOrder怎么用?PHP SQLSelect::AddOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLSelect
的用法示例。
在下文中一共展示了SQLSelect::AddOrder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Load
function Load( $cached = false ) {
$s = new SQLSelect();
$s->AddTable("buttons");
$s->AddOrder("rand()");
$s->AddWhere("dead = 0");
$s->SetLimit("1");
$this->data = SQLLib::SelectRow($s->GetQuery());
$this->title = $this->data->type;
}
示例2: if
<?
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("id");
$sql->AddField("nickname as name");
$sql->AddField("avatar");
$sql->AddField("glops");
$sql->AddTable("users");
$r = array();
if ($_POST["search"])
{
$sql->AddWhere(sprintf_esc("nickname like '%%%s%%'",_like($_POST["search"])));
$sql->AddOrder(sprintf_esc("if(nickname='%s',1,2), nickname, lastLogin DESC",$_POST["search"]));
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
$sql->AddWhere(sprintf_esc("id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
示例3: if
<?
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("prods.id");
$sql->AddField("prods.name");
$sql->AddField("groups.name as groupName");
$sql->AddJoin("left","groups","groups.id = prods.group1");
$sql->AddTable("prods");
$r = array();
if ($_POST["search"])
{
$sql->AddWhere(sprintf_esc("prods.name like '%%%s%%'",_like($_POST["search"])));
$sql->AddOrder(sprintf_esc("if(prods.name='%s',1,2), prods.views desc, prods.name",$_POST["search"]));
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
$sql->AddWhere(sprintf_esc("prods.id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
示例4: if
<?
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("id");
$sql->AddField("name");
$sql->AddTable("boards");
$r = array();
if ($_POST["search"])
{
$sql->AddWhere(sprintf_esc("name like '%%%s%%'",_like($_POST["search"])));
$sql->AddOrder(sprintf_esc("if(name='%s',1,2), name",$_POST["search"]));
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
$sql->AddWhere(sprintf_esc("id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
示例5: pouetAdmin_recacheTopDemos
function pouetAdmin_recacheTopDemos()
{
global $timer;
// this needs to be made faster. a LOT faster.
$total = array();
// list by views
$timer["recache_views"]["start"] = microtime_float();
$i=0;
$query="SELECT id,name,views FROM prods ORDER BY views DESC";
$result = SQLLib::Query($query);
$content = "<ol>";
while($tmp = SQLLib::Fetch($result)) {
$total[$tmp->id]+=$i;
$i++;
if ($i<=5)
$content .= "<li><b>"._html($tmp->name)."</b> - ".$tmp->views." views</li>\n";
}
$content .= "</ol>";
$content .= "<h3>".$i." prod views loaded</h3>\n";
$timer["recache_views"]["end"] = microtime_float();
$i=0;
// Get the list of prod IDs ordered by the sum of their comment ratings
$sql = new SQLSelect();
$sql->AddField("prods.id");
$sql->AddField("prods.name");
$sql->AddField("SUM(comments.rating) as theSum");
$sql->AddTable("prods");
$sql->AddJoin("","comments","prods.id = comments.which");
$sql->AddGroup("prods.id");
$sql->AddOrder("SUM(comments.rating) DESC");
$timer["recache_votes"]["start"] = microtime_float();
$result = SQLLib::Query( $sql->GetQuery() );
$content .= "<ol>";
while($tmp = SQLLib::Fetch($result)) {
$total[$tmp->id]+=$i;
$i++;
if ($i<=5)
$content .= "<li><b>"._html($tmp->name)."</b> - "._html($tmp->theSum)." votes</li>\n";
}
$content .= "</ol>";
$content .= "<h3>".$i." vote counts loaded</h3>\n";
$timer["recache_votes"]["end"] = microtime_float();
$timer["recache_sort"]["start"] = microtime_float();
asort($total);
$timer["recache_sort"]["end"] = microtime_float();
$timer["recache_update"]["start"] = microtime_float();
$i=1;
unset($tmp);
unset($top_demos);
$a = array();
while ((list ($key, $val)=each($total)))
{
$a[] = array(
"id" => $key,
"rank" => $i,
);
if (count($a) == 100)
{
SQLLib::UpdateRowMulti("prods","id",$a);
$a = array();
}
$i++;
}
SQLLib::UpdateRowMulti("prods","id",$a);
$content .= "<h3>".$i." prod rankings updated</h3>\n";
$timer["recache_update"]["end"] = microtime_float();
@unlink('cache/pouetbox_topalltime.cache');
@unlink('cache/pouetbox_topmonth.cache');
return $content;
}
示例6: RenderFooter
echo "<img src='".POUET_CONTENT_URL."gfx/".$lama_pictures[array_rand($lama_pictures)]."' alt='Lamer picture'/>";
}
function RenderFooter() {
echo " <div class='foot'><a href='".POUET_ROOT_URL."'>get back</a></div>\n";
echo "</div>\n";
}
};
$sel = new SQLSelect();
$sel->AddField("logos.id as id");
$sel->AddField("logos.file as file");
$sel->AddTable("logos");
$sel->AddJoin("LEFT","logos_votes",sprintf_esc("logos_votes.logo = logos.id AND logos_votes.user = %d",$currentUser->id));
$sel->AddWhere("logos_votes.id IS NULL");
$sel->AddOrder("RAND()");
if (get_login_id() && $_POST["logoID"] && $_POST["submit"])
{
$vote = 0;
if ($_POST["submit"] == "rulez") $vote = 1;
if ($_POST["submit"] == "sucks") $vote = -1;
$csrf = new CSRFProtect();
if ($vote && $csrf->ValidateToken())
{
SQLLib::Query(sprintf_esc("delete from logos_votes where logo = %d and user = %d",$_POST["logoID"],$currentUser->id));
$a = array();
$a["logo"] = (int)$_POST["logoID"];
$a["user"] = $currentUser->id;