当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Select::union方法代码示例

本文整理汇总了PHP中Zend_Db_Select::union方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Select::union方法的具体用法?PHP Zend_Db_Select::union怎么用?PHP Zend_Db_Select::union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Select的用法示例。


在下文中一共展示了Zend_Db_Select::union方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getStaleWhispers

 public function getStaleWhispers(User_Model_User $user)
 {
     // To
     $toSelect = $this->select()->where('recipient_id = ?', $user->getIdentity())->where('recipient_deleted = ?', 0);
     // From
     $fromSelect = $this->select()->where('sender_id = ?', $user->getIdentity())->where('sender_deleted = ?', 0);
     // Union
     $select = new Zend_Db_Select($this->getAdapter());
     $select->union(array('(' . $toSelect->__toString() . ')'))->union(array('(' . $fromSelect->__toString() . ')'))->order('whisper_id ASC');
     // Get data
     $stmt = $this->_db->query($select);
     $rows = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     // Make rowset
     $data = array('table' => $this, 'data' => $rows, 'readOnly' => false, 'rowClass' => $this->getRowClass(), 'stored' => true);
     $rowsetClass = $this->getRowsetClass();
     if (!class_exists($rowsetClass)) {
         // require_once 'Zend/Loader.php';
         Zend_Loader::loadClass($rowsetClass);
     }
     return new $rowsetClass($data);
 }
开发者ID:robeendey,项目名称:ce,代码行数:21,代码来源:Whispers.php

示例2: getActivityAbout

 public function getActivityAbout(Core_Model_Item_Abstract $about, User_Model_User $user, array $params = array())
 {
     // Proc args
     extract($this->_getInfo($params));
     // action_id, limit, min_id, max_id
     // Prepare main query
     $streamTable = Engine_Api::_()->getDbtable('stream', 'activity');
     $db = $streamTable->getAdapter();
     $union = new Zend_Db_Select($db);
     // Prepare action types
     $masterActionTypes = Engine_Api::_()->getDbtable('actionTypes', 'activity')->getActionTypes();
     $subjectActionTypes = array();
     $objectActionTypes = array();
     // Filter types based on displayable
     foreach ($masterActionTypes as $type) {
         if ($type->displayable & 1) {
             $subjectActionTypes[] = $type->type;
         }
         if ($type->displayable & 2) {
             $objectActionTypes[] = $type->type;
         }
     }
     // Filter types based on user request
     if (isset($showTypes) && is_array($showTypes) && !empty($showTypes)) {
         $subjectActionTypes = array_intersect($subjectActionTypes, $showTypes);
         $objectActionTypes = array_intersect($objectActionTypes, $showTypes);
     } else {
         if (isset($hideTypes) && is_array($hideTypes) && !empty($hideTypes)) {
             $subjectActionTypes = array_diff($subjectActionTypes, $hideTypes);
             $objectActionTypes = array_diff($objectActionTypes, $hideTypes);
         }
     }
     // Nothing to show
     if (empty($subjectActionTypes) && empty($objectActionTypes)) {
         return null;
     }
     if (empty($subjectActionTypes)) {
         $subjectActionTypes = null;
     } else {
         if (count($subjectActionTypes) == count($masterActionTypes)) {
             $subjectActionTypes = true;
         } else {
             $subjectActionTypes = "'" . join("', '", $subjectActionTypes) . "'";
         }
     }
     if (empty($objectActionTypes)) {
         $objectActionTypes = null;
     } else {
         if (count($objectActionTypes) == count($masterActionTypes)) {
             $objectActionTypes = true;
         } else {
             $objectActionTypes = "'" . join("', '", $objectActionTypes) . "'";
         }
     }
     // Prepare sub queries
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('getActivity', array('for' => $user, 'about' => $about));
     $responses = (array) $event->getResponses();
     if (empty($responses)) {
         return null;
     }
     foreach ($responses as $response) {
         if (empty($response)) {
             continue;
         }
         // Target info
         $select = $streamTable->select()->from($streamTable->info('name'), 'action_id')->where('target_type = ?', $response['type']);
         if (empty($response['data'])) {
             // Simple
             $select->where('target_id = ?', 0);
         } else {
             if (is_scalar($response['data']) || count($response['data']) === 1) {
                 // Single
                 if (is_array($response['data'])) {
                     list($response['data']) = $response['data'];
                 }
                 $select->where('target_id = ?', $response['data']);
             } else {
                 if (is_array($response['data'])) {
                     // Array
                     $select->where('target_id IN(?)', (array) $response['data']);
                 } else {
                     // Unknown
                     continue;
                 }
             }
         }
         // Add action_id/max_id/min_id
         if (null !== $action_id) {
             $select->where('action_id = ?', $action_id);
         } else {
             if (null !== $min_id) {
                 $select->where('action_id >= ?', $min_id);
             } else {
                 if (null !== $max_id) {
                     $select->where('action_id <= ?', $max_id);
                 }
             }
         }
         // Add order/limit
         $select->order('action_id DESC')->limit($limit);
//.........这里部分代码省略.........
开发者ID:HiLeo1610,项目名称:tumlumsach,代码行数:101,代码来源:Actions.php

示例3: getActivityAbout

 public function getActivityAbout(Core_Model_Item_Abstract $about, User_Model_User $user, array $params = array())
 {
     // Proc args
     extract($this->_getInfo($params));
     // action_id, limit, min_id, max_id, actionFilter, filterValue
     // Prepare main query
     $streamTable = Engine_Api::_()->getDbtable('stream', 'activity');
     $streamName = $streamTable->info('name');
     $actionTableName = $this->info('name');
     $db = $streamTable->getAdapter();
     $union = new Zend_Db_Select($db);
     // Prepare action types
     $masterActionTypes = Engine_Api::_()->getDbtable('actionTypes', 'activity')->getActionTypes();
     $subjectActionTypes = array();
     $objectActionTypes = array();
     // Filter types based on displayable
     foreach ($masterActionTypes as $type) {
         if ($about->getType() == 'event' && Engine_Api::_()->hasItemType('event') || $about->getType() == 'group' && Engine_Api::_()->hasItemType('group') || $about->getType() == 'ynbusinesspages_business' && Engine_Api::_()->hasItemType('ynbusinesspages_business')) {
             if ($actionFilter == 'owner' && isset($type->is_object_thumb) && !$type->is_object_thumb) {
                 continue;
             }
             if ($actionFilter == 'membership' && isset($type->is_object_thumb) && $type->is_object_thumb) {
                 continue;
             }
         }
         if ($type->displayable & 1) {
             $subjectActionTypes[] = $type->type;
         }
         if ($type->displayable & 2) {
             $objectActionTypes[] = $type->type;
         }
     }
     // Filter types based on user request
     if (isset($showTypes) && is_array($showTypes) && !empty($showTypes)) {
         $subjectActionTypes = array_intersect($subjectActionTypes, $showTypes);
         $objectActionTypes = array_intersect($objectActionTypes, $showTypes);
     } else {
         if (isset($hideTypes) && is_array($hideTypes) && !empty($hideTypes)) {
             $subjectActionTypes = array_diff($subjectActionTypes, $hideTypes);
             $objectActionTypes = array_diff($objectActionTypes, $hideTypes);
         }
     }
     // Nothing to show
     if (empty($subjectActionTypes) && empty($objectActionTypes)) {
         return null;
     }
     if (empty($subjectActionTypes)) {
         $subjectActionTypes = null;
     } else {
         if (count($subjectActionTypes) == count($masterActionTypes)) {
             $subjectActionTypes = true;
         } else {
             $subjectActionTypes = "'" . join("', '", $subjectActionTypes) . "'";
         }
     }
     if (empty($objectActionTypes)) {
         $objectActionTypes = null;
     } else {
         if (count($objectActionTypes) == count($masterActionTypes)) {
             $objectActionTypes = true;
         } else {
             $objectActionTypes = "'" . join("', '", $objectActionTypes) . "'";
         }
     }
     // Prepare sub queries
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('getActivity', array('for' => $user, 'about' => $about));
     $responses = (array) $event->getResponses();
     if (empty($responses)) {
         return null;
     }
     $friendsFlage = false;
     $action_ids = array();
     // Filter by hashtag
     if ($actionFilter == 'hashtag' && !empty($filterValue)) {
         $action_ids = Engine_Api::_()->getDbtable('hashtags', 'ynfeed')->getHashtagFeeds($filterValue, array(), array('limit' => $limit, 'max_id' => $max_id));
         if (empty($action_ids)) {
             return null;
         }
     }
     // Filter by login as business post
     if ($actionFilter == 'business') {
         $select = $this->select()->where('`subject_type` = ?', 'ynbusinesspages_business')->where('subject_id', $about->getIdentity())->limit($limit);
         if (null !== $max_id) {
             $select->where('action_id <= ?', $max_id);
         }
         $data = $select->query()->fetchAll();
         foreach ($data as $row) {
             $action_ids[] = $row['action_id'];
         }
         if (empty($action_ids)) {
             return null;
         }
     }
     $member_ids = array();
     if ($actionFilter == 'owner') {
         if ($about instanceof User_Model_User) {
             $member_ids[] = $about->getIdentity();
         } elseif ($about instanceof Group_Model_Group || $about instanceof Advgroup_Model_Group) {
             $objectParent = $about->getParent('user');
             if ($objectParent instanceof User_Model_User) {
//.........这里部分代码省略.........
开发者ID:hoalangoc,项目名称:ftf,代码行数:101,代码来源:Actions.php


注:本文中的Zend_Db_Select::union方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。