public function getPublicResultSet($userId, array $fields, $startIndex = 0, $count = 16, $sortBy = null, $sortOrder = null, Condition $con = null, $mode = 0, $class = null, array $args = array()) { $startIndex = $startIndex !== null ? (int) $startIndex : 0; $count = !empty($count) ? (int) $count : 16; $sortBy = $sortBy !== null ? $sortBy : 'date'; $sortOrder = $sortOrder !== null ? (int) $sortOrder : Sql::SORT_DESC; $select = $this->hm->getTable('AmunService\\User\\Activity\\Receiver')->select(array('id', 'status', 'activityId', 'userId', 'date'), 'receiver')->join(Join::INNER, $this->hm->getTable('AmunService\\User\\Activity')->select(array('id', 'globalId', 'parentId', 'userId', 'refId', 'table', 'status', 'scope', 'verb', 'summary', 'date'))->join(Join::INNER, $this->hm->getTable('AmunService\\User\\Account')->select(array('globalId', 'name', 'profileUrl', 'thumbnailUrl'), 'author')))->where('receiverUserId', '=', $userId)->where('receiverStatus', '=', Receiver\Record::VISIBLE)->where('parentId', '=', 0)->where('scope', '=', 0)->where('userId', '=', $userId)->orderBy($sortBy, $sortOrder)->limit($startIndex, $count); if (!empty($fields)) { $select->setSelectedColumns($fields); } if ($con !== null && $con->hasCondition()) { $values = $con->toArray(); foreach ($values as $row) { $select->where($row[0], $row[1], $row[2]); } } if ($mode == Sql::FETCH_OBJECT && $class === null) { $class = $this->getClassName(); } if ($mode == Sql::FETCH_OBJECT && empty($args)) { $args = $this->getClassArgs(); } $totalResults = $select->getTotalResults(); $entries = $select->getAll($mode, $class, $args); $resultSet = new ResultSet($totalResults, $startIndex, $count, $entries); return $resultSet; }
public function getPendingResultSet($userId, array $fields, $startIndex = 0, $count = 16, $sortBy = null, $sortOrder = null, Condition $con = null, $mode = 0, $class = null, array $args = array()) { $startIndex = $startIndex !== null ? (int) $startIndex : 0; $count = !empty($count) ? (int) $count : 16; $sortBy = $sortBy !== null ? $sortBy : 'date'; $sortOrder = $sortOrder !== null ? (int) $sortOrder : Sql::SORT_DESC; $select = $this->table->select(array('id', 'status', 'date'))->join(Join::INNER, $this->hm->getTable('AmunService\\User\\Account')->select(array('id', 'globalId', 'name', 'profileUrl', 'thumbnailUrl', 'updated', 'date'), 'author'), 'n:1', 'userId')->join(Join::INNER, $this->hm->getTable('AmunService\\User\\Account')->select(array('id', 'globalId', 'name', 'profileUrl', 'thumbnailUrl', 'updated', 'date'), 'friend'), 'n:1', 'friendId')->where('userId', '=', $userId)->where('status', '=', Record::REQUEST); if (!empty($fields)) { $select->select($fields); } if ($con !== null && $con->hasCondition()) { $values = $con->toArray(); foreach ($values as $row) { $select->where($row[0], $row[1], $row[2]); } } if ($mode == Sql::FETCH_OBJECT && $class === null) { $class = $this->getClassName(); } if ($mode == Sql::FETCH_OBJECT && empty($args)) { $args = $this->getClassArgs(); } $totalResults = $select->getTotalResults(); $entries = $select->getAll($mode, $class, $args); $resultSet = new ResultSet($totalResults, $startIndex, $count, $entries); return $resultSet; }
/** * Merges an existing condition * * @param \PSX\Sql\Condition $condition * @return \PSX\Sql\Condition */ public function merge(Condition $condition) { $this->values = array_merge($this->values, $condition->toArray()); return $this; }