Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function findUsersOfSite($siteId, $order = null, $paginated = false)
 {
     $sql = new Sql($this->dbAdapter);
     $membershipCols = array();
     foreach (DbSelectColumns::MEMBERSHIP as $col) {
         $membershipCols[DbViewMembership::TABLE . '_' . $col] = $col;
     }
     $activityCols = array();
     foreach (DbSelectColumns::USER_ACTIVITY as $col) {
         $activityCols[DbViewUserActivity::TABLE . '_' . $col] = $col;
     }
     $userCols = array();
     foreach (DbSelectColumns::USER as $col) {
         $userCols[DbViewUsers::TABLE . '_' . $col] = $col;
     }
     $select = $sql->select()->from(array('u' => DbViewUsers::TABLE))->columns($userCols)->join(array('a' => DbViewUserActivity::TABLE), 'u.' . DbViewUsers::USERID . ' = a.' . DbViewUserActivity::USERID, $activityCols)->join(array('m' => DbViewMembership::TABLE), 'm.' . DbViewMembership::USERID . ' = u.' . DbViewUsers::USERID . ' AND m.' . DbViewMembership::SITEID . ' = a.' . DbViewUserActivity::SITEID, $membershipCols, Select::JOIN_LEFT)->where(array('a.' . DbViewUserActivity::SITEID . ' = ?' => $siteId, '(m.' . DbViewMembership::JOINDATE . ' IS NOT NULL OR (a.' . DbViewUserActivity::VOTES . ' > 0) OR (a.' . DbViewUserActivity::REVISIONS . ' > 0) or (a.' . DbViewUserActivity::PAGES . ' > 0))'));
     if (is_array($order)) {
         $this->orderSelect($select, $order);
     }
     $resultSet = new \Zend\Db\ResultSet\HydratingResultSet($this->userSiteHydrator, $this->objectPrototype);
     if ($paginated) {
         $adapter = new \Zend\Paginator\Adapter\DbSelect($select, $this->dbAdapter, $resultSet);
         return new \Zend\Paginator\Paginator($adapter);
     }
     return $resultSet->initialize($this->fetch($sql, $select));
 }
Beispiel #2
0
 protected function hydrateResult($entityPrototype, $select, $displayQuery = false)
 {
     $statement = $this->sql->prepareStatementForSqlObject($select);
     if ($displayQuery) {
         echo "<br><br>" . $select->getSqlString($this->dbAdapter->getPlatform());
     }
     $results = $statement->execute();
     // 'ClassMethods' et al was not being found, so I used absolut path
     $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods();
     $resultset = new \Zend\Db\ResultSet\HydratingResultSet($hydrator, $entityPrototype);
     $resultset->initialize($results);
     return $resultset;
 }
Beispiel #3
0
 /**
  * Get package assignments
  *
  * @param string $order Package assignment property to sort by, default: PackageName
  * @param string $direction asc|desc, default: asc
  * @return \Zend\Db\ResultSet\AbstractResultSet Result set producing \Model\Package\Assignment
  */
 public function getPackageAssignments($order = 'PackageName', $direction = 'asc')
 {
     $hydrator = new \Zend\Stdlib\Hydrator\ArraySerializable();
     $hydrator->setNamingStrategy(new \Database\Hydrator\NamingStrategy\MapNamingStrategy(array('name' => 'PackageName', 'tvalue' => 'Status', 'comments' => 'Timestamp')));
     $hydrator->addStrategy('Timestamp', new \Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy(\Model\Package\Assignment::DATEFORMAT));
     $sql = $this->serviceLocator->get('Database\\Table\\ClientConfig')->getSql();
     $select = $sql->select();
     $select->columns(array('tvalue', 'comments'))->join('download_available', 'download_available.fileid = devices.ivalue', array('name'), \Zend\Db\Sql\Select::JOIN_INNER)->where(array('hardware_id' => $this['Id'], 'devices.name' => 'DOWNLOAD'))->order(array($hydrator->extractName($order) => $direction));
     $resultSet = new \Zend\Db\ResultSet\HydratingResultSet($hydrator, clone $this->serviceLocator->get('Model\\Package\\Assignment'));
     $resultSet->initialize($sql->prepareStatementForSqlObject($select)->execute());
     return $resultSet;
 }
Beispiel #4
0
 public function hydrate($results)
 {
     $deals = new \Zend\Db\ResultSet\HydratingResultSet($this->hydrator, $this->entityPrototype);
     return $deals->initialize($results);
 }