private function _add_customer_constraint($guid, midcom_core_query $qb) { try { $this->_request_data['customer'] = new org_openpsa_contacts_group_dba($guid); $qb->add_constraint('customer', '=', $this->_request_data['customer']->id); } catch (midcom_error $e) { $this->_request_data['customer'] = new org_openpsa_contacts_person_dba($guid); $qb->add_constraint('customerContact', '=', $this->_request_data['customer']->id); } return $qb; }
private function _get_rows() { $qb = $this->_prepare_query(); $this->_total_rows = $qb->count(); if ($this->_datatype == 'json' && !empty($this->_results_per_page)) { $this->_query->set_limit($this->_results_per_page); if (!empty($this->_offset)) { $this->_query->set_offset($this->_offset); } } $this->_rows = array(); if ($qb instanceof midcom_core_querybuilder) { $items = $qb->execute(); } else { if ($qb instanceof midcom_core_collector) { $items = $qb->get_objects(); } else { throw new midcom_error('Unsupported query class ' . get_class($qb)); } } foreach ($items as $item) { $this->_rows[] = $this->_client->get_row($item); } }
/** * Resets some internal variables for re-execute */ protected function _reset() { $this->_qb_error_result = 'UNDEFINED'; parent::_reset(); }
/** * Add username order to a query instance, with differences between * mgd1 and mgd2 abstracted away. * * Note that it actually does nothing under mgd2 right now, because it's still * unclear how this could be implemented * * @param midcom_core_query &$query The QB or MC instance to work on * @param string $direction The value for the username constraint */ public static function add_username_order(midcom_core_query &$query, $direction) { if (method_exists('midgard_user', 'login')) { debug_add('Ordering persons by username is not yet implemented for Midgard2', MIDCOM_LOG_ERROR); //@todo Find a way to do this } else { $query->add_order('username', $direction); } }
private function _apply_constraints(midcom_core_query &$qb, array $fields) { if (sizeof($this->_query) > 1) { //if we have more than one token in the query, we try to match the entire string as well $qb->begin_group('OR'); foreach ($fields as $field) { if (empty($field)) { continue; } $qb->add_constraint($field, 'LIKE', str_replace('__TERM__', $this->_query_string_processed, $this->_wildcard_template)); } } $qb->begin_group('AND'); foreach ($this->_query as $term) { $qb->begin_group('OR'); foreach ($fields as $field) { if (empty($field)) { continue; } $qb->add_constraint($field, 'LIKE', str_replace('__TERM__', $term, $this->_wildcard_template)); } $qb->end_group(); } $qb->end_group(); if (sizeof($this->_query) > 1) { $qb->end_group(); } }