* @var int
*/
const
+ NO_RETURN_PROPERTIES = 'CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES',
MODE_CONTACTS = 1,
MODE_CONTRIBUTE = 2,
MODE_MEMBER = 8,
$this->_params = array();
}
- if (empty($returnProperties)) {
+ if ($returnProperties === self::NO_RETURN_PROPERTIES) {
+ $this->_returnProperties = array();
+ }
+ elseif (empty($returnProperties)) {
$this->_returnProperties = self::defaultReturnProperties($mode);
}
else {
if (!$displayRelationshipType) {
$query = new CRM_Contact_BAO_Query($params,
- $this->_returnProperties,
- NULL, FALSE, FALSE, 1,
+ CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES,
+ array('contact_id'), FALSE, FALSE, 1,
FALSE, TRUE, TRUE, NULL,
$queryOperator
);
}
else {
- $query = new CRM_Contact_BAO_Query($params, $this->_returnProperties,
- NULL, FALSE, FALSE, 1,
+ $query = new CRM_Contact_BAO_Query($params,
+ CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES,
+ array('contact_id'), FALSE, FALSE, 1,
FALSE, TRUE, TRUE, $displayRelationshipType,
$queryOperator
);
static $_checkedSqlFunctionsExist = FALSE;
+ /**
+ * https://issues.civicrm.org/jira/browse/CRM-17748
+ * internal variable for DAO to hold per-query settings
+ */
+ protected $_options = array();
+
/**
* Class constructor.
*
*/
public function query($query, $i18nRewrite = TRUE) {
// rewrite queries that should use $dbLocale-based views for multi-language installs
- global $dbLocale;
+ global $dbLocale, $_DB_DATAOBJECT;
+
+ $conn = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
+ $orig_options = $conn->options;
+ $this->_setDBOptions($this->_options);
+
if ($i18nRewrite and $dbLocale) {
$query = CRM_Core_I18n_Schema::rewriteQuery($query);
}
- return parent::query($query);
+ $ret = parent::query($query);
+
+ $this->_setDBOptions($orig_options);
+ return $ret;
}
/**
}
/**
+ * https://issues.civicrm.org/jira/browse/CRM-17748
+ * Sets the internal options to be used on a query
+ *
+ * @param array $options
+ *
+ */
+ function setOptions($options) {
+ if (is_array($options)) {
+ $this->_options = $options;
+ }
+ }
+
+ /**
+ * https://issues.civicrm.org/jira/browse/CRM-17748
+ * wrapper to pass internal DAO options down to DB_mysql/DB_Common level
+ *
+ * @param array $options
+ *
+ */
+ protected function _setDBOptions($options) {
+ global $_DB_DATAOBJECT;
+
+ if (is_array($options) && count($options)) {
+ $conn = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
+ foreach ($options as $option_name => $option_value) {
+ $conn->setOption($option_name, $option_value);
+ }
+ }
+ }
+
+ /**
* @param array $params
*/
public function setApiFilter(&$params) {