public function tripal_views_query::init

3.x tripal_views_query.inc public tripal_views_query::init($base_table = 'tripal_entity', $base_field = 'id', $options)

File

tripal/tripal_views_query.inc, line 33

Class

tripal_views_query

Code

public function init($base_table = 'tripal_entity', $base_field = 'id', $options) {
  parent::init($base_table, $base_field, $options);
  $this->fields = array();
  $this->where = array();
  $this->order = array();

  // Creqte the TripalFieldQuery object.
  $this->query = new TripalFieldQuery();
  $this->cquery = new TripalFieldQuery();
  $this->cquery->count();

  // Convert the $base_table into the bundle table.  Because every
  // tripal site will have different bundle tables we have to do the
  // conversion for cross-site compatibility.
  list($vocabulary, $accession) = explode('__', $base_table);
  $term = tripal_load_term_entity(array('vocabulary' => $vocabulary, 'accession' => $accession));
  $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));

  // Make sure we only query on the entities for this bundle type.
  $this->query->entityCondition('entity_type', 'TripalEntity');
  $this->query->entityCondition('bundle', $bundle->name);

  $this->cquery->entityCondition('entity_type', 'TripalEntity');
  $this->cquery->entityCondition('bundle', $bundle->name);
}