public function taxrank__infraspecific_taxon::query

3.x taxrank__infraspecific_taxon.inc public taxrank__infraspecific_taxon::query($query, $condition)

Overrides ChadoField::query

See also

ChadoField::query()

File

tripal_chado/includes/TripalFields/taxrank__infraspecific_taxon/taxrank__infraspecific_taxon.inc, line 112

Class

taxrank__infraspecific_taxon

Code

public function query($query, $condition) {
  $alias = $this->field['field_name'];
  $operator = $condition['operator'];

  $field_term_id = $this->getFieldTermID();
  $label_term = $field_term_id . ',' . 'rdfs:label';
  $infraspecific_name_term = $field_term_id . ',' . chado_get_semweb_term('organism', 'infraspecific_name');
  $infraspecific_type_term = $field_term_id . ',' . chado_get_semweb_term('organism', 'type_id');

  if ($condition['column'] == $label_term or $condition['column'] == $field_term_id) {
    $this->queryJoinOnce($query, 'cvterm', $alias . '_cvterm', $alias . "_cvterm.cvterm_id = base.type_id");
    $query->where("CONCAT(" . $alias . "_cvterm.name, ' ', base.infraspecific_name) $operator :full_name", array(':full_name' => $condition['value']));
  }
  if ($condition['column'] == $infraspecific_name_term) {
    $query->condition('base.infraspecific_name', $condition['value'], $operator);
  }
  if ($condition['column'] == $infraspecific_type_term) {
    $this->queryJoinOnce($query, 'cvterm', $alias . '_cvterm', $alias . "_cvterm.cvterm_id = base.type_id");
    $query->condition($alias . '_cvterm.name', $condition['value'], $operator);
  }
}