public function local__contact::queryOrder
3.x local__contact.inc | public local__contact::queryOrder($query, $order) |
Overrides ChadoField::queryOrder
See also
File
- tripal_chado/
includes/ TripalFields/ local__contact/ local__contact.inc, line 200
Class
Code
public function queryOrder($query, $order) {
$alias = $this->field['field_name'];
$field_term_id = $this->getFieldTermID();
$type_term = chado_get_semweb_term('contact', 'type_id');
$name_term = chado_get_semweb_term('contact', 'name');
$description_term = chado_get_semweb_term('contact', 'description');
if ($field_table == 'biomaterial') {
if ($record) {
$contact = $record->biosourceprovider_id;
// Join the contact linker table and then join the contact table.
$calias = $alias . '_provider_id';
$this->queryJoinOnce($query, 'contact', $calias, "base.biosourceprovider_id = $calias.contact_id");
// Search by the contact name
if ($order['column'] == $field_term_id or
$order['column'] == $field_term_id . ',' . $name_term) {
$query->orderBy("$calias.name", $order['direction']);
}
// Search on the contact description.
if ($order['column'] == $field_term_id . ',' . $description_term) {
$query->orderBy("$calias.description", $order['direction']);
}
// Search on the contact type.
if ($order['column'] == $field_term_id . ',' . $type_term) {
$talias = $alias . 'provider_contact_type';
$this->queryJoinOnce($query, 'cvterm', $talias, "$calias.type_id = $talias.cvterm_id", "LEFT OUTER");
$query->orderBy("$talias.name", $order['direction']);
}
}
}
}