class PagerActivity in Heartbeat 7
Query extender for heartbeat pager queries.
Hierarchy
- class \SelectQueryExtender implements SelectQueryInterface- class \PagerActivity
 
Expanded class hierarchy of PagerActivity
1 string reference to 'PagerActivity'
- HeartbeatStream::createQuery in includes/heartbeatstream.inc 
- createQuery().
File
- ./heartbeat.module, line 1170 
- Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.
View source
class PagerActivity extends SelectQueryExtender {
  public $lastActivityId = 0;
  /**
   * The limit for this pager.
   */
  protected $limit = 0;
  public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
    parent::__construct($query, $connection);
    // Add pager tag. Do this here to ensure that it is always added before
    // preExecute() is called.
    $this
      ->addTag('pager');
  }
  /**
   * Override the execute method.
   *
   * Before we run the query, we need to add pager-based range() instructions
   * to it.
   */
  public function execute() {
    // Add convenience tag to mark that this is an extended query. We have to
    // do this in the constructor to ensure that it is set before preExecute()
    // gets called.
    if (!$this
      ->preExecute($this)) {
      return NULL;
    }
    // A NULL limit is the "kill switch" for pager queries.
    if (empty($this->limit)) {
      return;
    }
    //$total_items = $this->getCountQuery()->execute()->fetchField();
    //$current_page = pager_default_initialize($total_items, $this->limit, $this->element);
    $this
      ->range(0, $this->limit);
    // Now that we've added our pager-based range instructions, run the query normally.
    return $this->query
      ->execute();
  }
  /**
   * Sets the last uaid
   */
  public function setLastActivityId($lastActivityId) {
    $this->lastActivityId = $lastActivityId;
    $this->query
      ->condition('ha.uaid', $this->lastActivityId, '>');
  }
  /**
   * Sets the offset timestamps.
   */
  public function setOffsetTime($before, $after = 0) {
    $this->query
      ->condition('ha.timestamp', $before, '<');
    if ($after > 0) {
      $this->query
        ->condition('ha.timestamp', $_SERVER['REQUEST_TIME'] - $after, '>');
    }
  }
  /**
   * Specify the maximum number of elements per page for this query.
   *
   * The default if not specified is 10 items per page.
   *
   * @param $limit
   *   An integer specifying the number of elements per page.  If passed a false
   *   value (FALSE, 0, NULL), the pager is disabled.
   */
  public function limit($limit = 10) {
    $this->limit = $limit;
    return $this;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| PagerActivity:: | public | property | ||
| PagerActivity:: | protected | property | The limit for this pager. | |
| PagerActivity:: | public | function | Override the execute method. Overrides SelectQueryExtender:: | |
| PagerActivity:: | public | function | Specify the maximum number of elements per page for this query. | |
| PagerActivity:: | public | function | Sets the last uaid | |
| PagerActivity:: | public | function | Sets the offset timestamps. | |
| PagerActivity:: | public | function | Overrides SelectQueryExtender:: | |
| SelectQueryExtender:: | protected | property | The connection object on which to run this query. | |
| SelectQueryExtender:: | protected | property | The placeholder counter. | |
| SelectQueryExtender:: | protected | property | The SelectQuery object we are extending/decorating. | |
| SelectQueryExtender:: | protected | property | A unique identifier for this query object. | |
| SelectQueryExtender:: | public | function | Adds an expression to the list of "fields" to be SELECTed. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Adds a field to the list to be SELECTed. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Join against another table in the database. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Adds additional metadata to the query. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | Adds a tag to a query. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | Gets a complete list of all values to insert into the prepared statement. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Compiles the saved conditions for later retrieval. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Check whether a condition has been previously compiled. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Helper function: builds the most common conditional clauses. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Gets a complete list of all conditions in this conditional clause. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Get the equivalent COUNT query of this query as a new query object. Overrides SelectQueryInterface:: | 1 | 
| SelectQueryExtender:: | public | function | Sets this query to be DISTINCT. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Sets a condition that the specified subquery returns values. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Enhance this object by wrapping it in an extender object. Overrides QueryExtendableInterface:: | |
| SelectQueryExtender:: | public | function | Add multiple fields from the same table to be SELECTed. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Add FOR UPDATE to the query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Compiles and returns an associative array of the arguments for this prepared statement. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the expressions array for this query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the fields array for this query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the group-by array for this query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Retrieves a given piece of metadata. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the order by array for this query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the tables array for this query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Returns a reference to the union queries for this query. This include
queries for UNION, UNION ALL, and UNION DISTINCT. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Groups the result set by the specified field. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Determines if a given query has all specified tags. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | Determines if a given query has any specified tag. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | Determines if a given query has a given tag. Overrides QueryAlterableInterface:: | |
| SelectQueryExtender:: | public | function | ||
| SelectQueryExtender:: | public | function | ||
| SelectQueryExtender:: | public | function | ||
| SelectQueryExtender:: | public | function | Helper function to build most common HAVING conditional clauses. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | ||
| SelectQueryExtender:: | public | function | Inner Join against another table in the database. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | function | Sets a condition that the specified field be NOT NULL. Overrides QueryConditionInterface:: | ||
| SelectQueryExtender:: | function | Sets a condition that the specified field be NULL. Overrides QueryConditionInterface:: | ||
| SelectQueryExtender:: | public | function | Indicates if preExecute() has already been called on that object. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Default Join against another table in the database. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Left Outer Join against another table in the database. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Implements QueryPlaceholderInterface::nextPlaceholder(). Overrides QueryPlaceholderInterface:: | |
| SelectQueryExtender:: | public | function | Sets a condition that the specified subquery returns no values. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Orders the result set by a given field. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Orders the result set by a random value. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Generic preparation and validation for a SELECT query. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Restricts a query to a given range in the result set. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Right Outer Join against another table in the database. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Add another Select query to UNION to this one. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | Implements QueryPlaceholderInterface::uniqueIdentifier(). Overrides QueryPlaceholderInterface:: | |
| SelectQueryExtender:: | public | function | Adds an arbitrary WHERE clause to the query. Overrides QueryConditionInterface:: | |
| SelectQueryExtender:: | public | function | Magic override for undefined methods. | |
| SelectQueryExtender:: | public | function | Clone magic method. Overrides SelectQueryInterface:: | |
| SelectQueryExtender:: | public | function | 
