本文整理汇总了PHP中Gdn_DataSet::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_DataSet::join方法的具体用法?PHP Gdn_DataSet::join怎么用?PHP Gdn_DataSet::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_DataSet
的用法示例。
在下文中一共展示了Gdn_DataSet::join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get2
/**
* Get a list of conversations for a user's inbox. This is an optimized version of ConversationModel::get().
*
* @param int $UserID The user looking at the conversations.
* @param int $Offset Number to skip.
* @param int $Limit Maximum to return.
*/
public function get2($UserID, $Offset = 0, $Limit = 0)
{
if ($Limit <= 0) {
$Limit = c('Conversations.Conversations.PerPage', 30);
}
// The self join is intentional in order to force the query to us an index-scan instead of a table-scan.
$Data = $this->SQL->select('c.*')->select('uc2.DateLastViewed')->select('uc2.CountReadMessages')->select('uc2.LastMessageID', '', 'UserLastMessageID')->from('UserConversation uc')->join('UserConversation uc2', 'uc.ConversationID = uc2.ConversationID and uc.UserID = uc2.UserID')->join('Conversation c', 'c.ConversationID = uc2.ConversationID')->where('uc.UserID', $UserID)->where('uc.Deleted', 0)->orderBy('uc.DateConversationUpdated', 'desc')->limit($Limit, $Offset)->get();
$Data->datasetType(DATASET_TYPE_ARRAY);
$Result =& $Data->result();
// Add some calculated fields.
foreach ($Result as &$Row) {
if ($Row['UserLastMessageID']) {
$Row['LastMessageID'] = $Row['UserLastMessageID'];
}
$Row['CountNewMessages'] = $Row['CountMessages'] - $Row['CountReadMessages'];
unset($Row['UserLastMessageID']);
}
// Join the participants.
$this->joinParticipants($Result);
// Join in the last message.
Gdn_DataSet::join($Result, array('table' => 'ConversationMessage', 'prefix' => 'Last', 'parent' => 'LastMessageID', 'child' => 'MessageID', 'InsertUserID', 'DateInserted', 'Body', 'Format'));
return $Data;
}
示例2: joinAddons
/**
*
*
* @param $Data
* @param string $Field
* @param array $Columns
* @throws
* @throws Exception
*/
public static function joinAddons(&$Data, $Field = 'AddonID', $Columns = array('Name'))
{
$Columns = array_merge(array('table' => 'Addon', 'column' => 'Addon'), $Columns);
Gdn_DataSet::join($Data, $Columns, array('unique' => true));
}