本文整理汇总了PHP中Gdn::Sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Sql方法的具体用法?PHP Gdn::Sql怎么用?PHP Gdn::Sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ToString
public function ToString($Results)
{
$UserIDs = array();
foreach ($Results as $Row) {
$UserIDs[] = $Row->{SS_ATTR_USERID};
///IMPORTANT, this is lowercase since grab results directly from sphinx
}
// print_r($Return); die;
$Sql = clone Gdn::Sql();
$Users = $Sql->Select('Photo, UserID, Name')->From('User')->WhereIn('UserID', $UserIDs)->Get()->ResultObject();
ob_start();
?>
<div id="People" class="Box People">
<h4 class="Header"><?php
echo T('People');
?>
</h4>
<ul class="PanelInfo PanelDiscussions">
<?php
foreach ($Users as $Row) {
?>
<li class="Item">
<?php
$User = UserBuilder($Row);
?>
<?php
echo UserPhoto($User);
echo UserAnchor($User);
?>
</li>
<?php
}
?>
</ul>
</div>
<?php
$String = ob_get_contents();
@ob_end_clean();
return $String;
}
示例2: _SetTagSql
/**
*
* @param Gdn_SQLDriver $Sql
*/
protected function _SetTagSql($Sql, $Tag, &$Limit, &$Offset = 0, $Op = 'or')
{
$SortField = 'd.DateLastComment';
$SortDirection = 'desc';
$TagSql = clone Gdn::Sql();
if ($DateFrom = Gdn::Request()->Get('DateFrom')) {
// Find the discussion ID of the first discussion created on or after the date from.
$DiscussionIDFrom = $TagSql->GetWhere('Discussion', array('DateInserted >= ' => $DateFrom), 'DiscussionID', 'asc', 1)->Value('DiscussionID');
$SortField = 'd.DiscussionID';
}
$Tags = array_map('trim', explode(',', $Tag));
$TagIDs = $TagSql->Select('TagID')->From('Tag')->WhereIn('Name', $Tags)->Get()->ResultArray();
$TagIDs = ConsolidateArrayValuesByKey($TagIDs, 'TagID');
if ($Op == 'and' && count($Tags) > 1) {
$DiscussionIDs = $TagSql->Select('DiscussionID')->Select('TagID', 'count', 'CountTags')->From('TagDiscussion')->WhereIn('TagID', $TagIDs)->GroupBy('DiscussionID')->Having('CountTags >=', count($Tags))->Limit($Limit, $Offset)->OrderBy('DiscussionID', 'desc')->Get()->ResultArray();
$Limit = '';
$Offset = 0;
$DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');
$Sql->WhereIn('d.DiscussionID', $DiscussionIDs);
$SortField = 'd.DiscussionID';
} else {
$Sql->Join('TagDiscussion td', 'd.DiscussionID = td.DiscussionID')->Limit($Limit, $Offset)->WhereIn('td.TagID', $TagIDs);
if ($Op == 'and') {
$SortField = 'd.DiscussionID';
}
}
// Set up the sort field and direction.
SaveToConfig(array('Vanilla.Discussions.SortField' => $SortField, 'Vanilla.Discussions.SortDirection' => $SortDirection), '', FALSE);
}
示例3: get_user_token_for_user_id
public function get_user_token_for_user_id($user_id)
{
// Read the user_id for this login_token
$result = Gdn::Sql()->Select('user_token')->From('oasl_user')->Where('user_id', intval($user_id))->Get()->Result(DATASET_TYPE_ARRAY);
foreach ($result as $row) {
$user_token = GetValue('user_token', $row);
if ($user_token !== FALSE) {
return $user_token;
}
}
// Not found
return FALSE;
}