class views_plugin_query
The base query class, which is the underlying layer in a View.
Hierarchy
- class \views_object
- class \views_plugin extends \views_object
- class \views_plugin_query extends \views_plugin
 
 
 - class \views_plugin extends \views_object
 
Expanded class hierarchy of views_plugin_query
Related topics
1 string reference to 'views_plugin_query'
- views_views_plugins in includes/
plugins.inc  - Implements hook_views_plugins().
 
File
- 
              plugins/
views_plugin_query.inc, line 19  
View source
class views_plugin_query extends views_plugin {
  
  /**
   * A pager plugin that should be provided by the display.
   *
   * @var views_plugin_pager
   */
  public $pager = NULL;
  
  /**
   * Constructor; Create the basic query object and fill with default values.
   */
  public function init($base_table, $base_field, $options) {
    $this->base_table = $base_table;
    $this->base_field = $base_field;
    $this->unpack_options($this->options, $options);
  }
  
  /**
   * Generate a query and a countquery from all of the information supplied
   * to the object.
   *
   * @param bool $get_count
   *   Provide a countquery if this is TRUE, otherwise provide a normal query.
   *
   * @return SelectQuery
   *   A SelectQuery object.
   */
  public function query($get_count = FALSE) {
  }
  
  /**
   * Let modules modify the query just prior to finalizing it.
   *
   * @param view $view
   *   The view which is executed.
   */
  public function alter(&$view) {
  }
  
  /**
   * Builds the necessary info to execute the query.
   *
   * @param view $view
   *   The view which is executed.
   */
  public function build(&$view) {
  }
  
  /**
   * Executes the query and fills the associated view object with according
   * values.
   *
   * Values to set: $view->result, $view->total_rows, $view->execute_time,
   * $view->pager['current_page'].
   *
   * $view->result should contain an array of objects. The array must use a
   * numeric index starting at 0.
   *
   * @param view $view
   *   The view which is executed.
   */
  public function execute(&$view) {
  }
  
  /**
   * Add a signature to the query, if such a thing is feasible.
   *
   * This signature is something that can be used when perusing query logs to
   * discern where particular queries might be coming from.
   *
   * @param view $view
   *   The view which is executed.
   */
  public function add_signature(&$view) {
  }
  
  /**
   * Get aggregation info for group by queries.
   *
   * If NULL, aggregation is not allowed.
   */
  public function get_aggregation_info() {
  }
  
  /**
   * Add settings for the ui.
   */
  public function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
  }
  
  /**
   * {@inheritdoc}
   */
  public function options_validate(&$form, &$form_state) {
  }
  
  /**
   * {@inheritdoc}
   */
  public function options_submit(&$form, &$form_state) {
  }
  
  /**
   * {@inheritdoc}
   */
  public function summary_title() {
    return t('Settings');
  }
  
  /**
   * Set a LIMIT on the query, specifying a maximum number of results.
   */
  public function set_limit($limit) {
    $this->limit = $limit;
  }
  
  /**
   * Set an OFFSET on the query, specifying a number of results to skip.
   */
  public function set_offset($offset) {
    $this->offset = $offset;
  }
  
  /**
   * Render the pager, if necessary.
   */
  public function render_pager($exposed_input) {
    if (!empty($this->pager) && $this->pager
      ->use_pager()) {
      return $this->pager
        ->render($exposed_input);
    }
    return '';
  }
  
  /**
   * Create a new grouping for the WHERE or HAVING clause.
   *
   * @param string $type
   *   Either 'AND' or 'OR'. All items within this group will be added
   *   to the WHERE clause with this logical operator.
   * @param string $group
   *   An ID to use for this group. If unspecified, an ID will be generated.
   * @param string $where
   *   'where' or 'having'.
   *
   * @return string
   *   The group ID generated.
   */
  public function set_where_group($type = 'AND', $group = NULL, $where = 'where') {
    // Set an alias.
    $groups =& $this->{$where};
    if (!isset($group)) {
      $group = empty($groups) ? 1 : max(array_keys($groups)) + 1;
    }
    // Create an empty group.
    if (empty($groups[$group])) {
      $groups[$group] = array(
        'conditions' => array(),
        'args' => array(),
      );
    }
    $groups[$group]['type'] = strtoupper($type);
    return $group;
  }
  
  /**
   * Control how all WHERE and HAVING groups are put together.
   *
   * @param string $type
   *   Either 'AND' or 'OR'.
   */
  public function set_group_operator($type = 'AND') {
    $this->group_operator = strtoupper($type);
  }
  
  /**
   * Returns the according entity objects for the given query results.
   */
  public function get_result_entities($results, $relationship = NULL) {
    return FALSE;
  }
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides | 
|---|---|---|---|---|---|---|
| views_object::$definition | public | property | Handler's definition. | |||
| views_object::$options | public | property | Except for displays, options for the object will be held here. | 1 | ||
| views_object::altered_option_definition | public | function | Collect this handler's option definition and alter them, ready for use. | |||
| views_object::construct | public | function | Views handlers use a special construct function. | 4 | ||
| views_object::destroy | public | function | Destructor. | 2 | ||
| views_object::export_option | public | function | 1 | |||
| views_object::export_options | public | function | ||||
| views_object::export_option_always | public | function | Always exports the option, regardless of the default value. | |||
| views_object::options | Deprecated | public | function | Set default options on this object. | 1 | |
| views_object::option_definition | public | function | Information about options for all kinds of purposes will be held here. | 13 | ||
| views_object::set_default_options | public | function | Set default options. | |||
| views_object::set_definition | public | function | Let the handler know what its full definition is. | |||
| views_object::unpack_options | public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.  | 
                            |||
| views_object::unpack_translatable | public | function | Unpack a single option definition. | |||
| views_object::unpack_translatables | public | function | Unpacks each handler to store translatable texts. | |||
| views_object::_set_option_defaults | public | function | ||||
| views_plugin::$display | public | property | The current used views display. | |||
| views_plugin::$plugin_name | public | property | The plugin name of this plugin, for example table or full. | |||
| views_plugin::$plugin_type | public | property | The plugin type of this plugin, for example style or query. | |||
| views_plugin::$view | public | property | The top object of a view. | Overrides views_object::$view | 1 | |
| views_plugin::additional_theme_functions | public | function | Provide a list of additional theme functions for the theme info page. | |||
| views_plugin::plugin_title | public | function | Return the human readable name of the display. | |||
| views_plugin::theme_functions | public | function | Provide a full list of possible theme templates used by this style. | |||
| views_plugin::validate | public | function | Validate that the plugin is correct and can be saved. | 3 | ||
| views_plugin_query::$pager | public | property | A pager plugin that should be provided by the display. | 1 | ||
| views_plugin_query::add_signature | public | function | Add a signature to the query, if such a thing is feasible. | 1 | ||
| views_plugin_query::alter | public | function | Let modules modify the query just prior to finalizing it. | 1 | ||
| views_plugin_query::build | public | function | Builds the necessary info to execute the query. | 1 | ||
| views_plugin_query::execute | public | function | Executes the query and fills the associated view object with according values.  | 
                            1 | ||
| views_plugin_query::get_aggregation_info | public | function | Get aggregation info for group by queries. | 1 | ||
| views_plugin_query::get_result_entities | public | function | Returns the according entity objects for the given query results. | 1 | ||
| views_plugin_query::init | public | function | Constructor; Create the basic query object and fill with default values. | 1 | ||
| views_plugin_query::options_form | public | function | Add settings for the ui. | Overrides views_plugin::options_form | 1 | |
| views_plugin_query::options_submit | public | function | Handle any special handling on the validate form. | Overrides views_plugin::options_submit | 1 | |
| views_plugin_query::options_validate | public | function | Validate the options form. | Overrides views_plugin::options_validate | ||
| views_plugin_query::query | public | function | Generate a query and a countquery from all of the information supplied to the object.  | 
                            Overrides views_plugin::query | 1 | |
| views_plugin_query::render_pager | public | function | Render the pager, if necessary. | |||
| views_plugin_query::set_group_operator | public | function | Control how all WHERE and HAVING groups are put together. | |||
| views_plugin_query::set_limit | public | function | Set a LIMIT on the query, specifying a maximum number of results. | |||
| views_plugin_query::set_offset | public | function | Set an OFFSET on the query, specifying a number of results to skip. | |||
| views_plugin_query::set_where_group | public | function | Create a new grouping for the WHERE or HAVING clause. | |||
| views_plugin_query::summary_title | public | function | Returns the summary of the settings in the display. | Overrides views_plugin::summary_title |