當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Gdn_DataSet::join方法代碼示例

本文整理匯總了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;
 }
開發者ID:vanilla,項目名稱:vanilla,代碼行數:30,代碼來源:class.conversationmodel.php

示例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));
 }
開發者ID:vanilla,項目名稱:community,代碼行數:14,代碼來源:class.addonmodel.php


注:本文中的Gdn_DataSet::join方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。