public function ChadoField::query
3.x ChadoField.inc | public ChadoField::query($query, $condition) |
In addition to the rules to follow for the TripalField::query function these should also be followed for the ChadoField::query implementation.
- When giving alias to joined tables be sure to use aliases that are unique to avoid conflicts with other fields.
- When joining with the base table its alias is 'base'.
- You may join to materialized views if need be to help speed queries.
Overrides TripalField::query
See also
16 methods override ChadoField::query()
- chado_linker__contact::query in tripal_chado/
includes/ TripalFields/ chado_linker__contact/ chado_linker__contact.inc - chado_linker__prop::query in tripal_chado/
includes/ TripalFields/ chado_linker__prop/ chado_linker__prop.inc - data__accession::query in tripal_chado/
includes/ TripalFields/ data__accession/ data__accession.inc - data__sequence_coordinates::query in tripal_chado/
includes/ TripalFields/ data__sequence_coordinates/ data__sequence_coordinates.inc - local__contact::query in tripal_chado/
includes/ TripalFields/ local__contact/ local__contact.inc
File
- tripal_chado/
includes/ TripalFields/ ChadoField.inc, line 67
Class
Code
public function query($query, $condition) {
// If we are here it is because the child class did not implement the
// query function. So, we will do our best to make the query work.
$chado_table = $this->instance['settings']['chado_table'];
$base_table = $this->instance['settings']['base_table'];
$bschema = chado_get_schema($base_table);
$bpkey = $bschema['primary key'][0];
$alias = 'dbx_linker';
$operator = $condition['operator'];
// If the chado_table and the base_table are the same then this is easy.
if ($chado_table == $base_table) {
// Get the base table column that is associated with the term
// passed as $condition['column'].
$base_field = chado_get_semweb_column($chado_table, $condition['column']);
$query->condition('base.' . $base_field, $condition['value'], $operator);
}
else {
// If the two are not the same then we expect that the child class
// will implement a query() function.
}
}