/** * Specific where clause override. * * @param array $field * @param string $op * @param mixed $value * @param float $min * @param float $max * * @return string */ public function whereClause(&$field, $op, $value, $min, $max) { if ($field['name'] == 'start_date') { $value = CRM_Utils_Type::escape($value, 'Int'); return " pledge_civireport.contact_id NOT IN ( SELECT distinct pledge.contact_id FROM civicrm_pledge pledge WHERE YEAR(pledge.start_date) >= $value AND pledge.is_test = 0) AND pledge_civireport.contact_id IN (SELECT distinct pledge.contact_id FROM civicrm_pledge pledge WHERE YEAR(pledge.start_date) = ($value - 1) AND pledge.is_test = 0 )"; } parent::whereClause($field, $op, $value, $min, $max); }
/** * Overriding this is the best way to alter the where statement for an individual field. * * @param array $field Field specifications * @param string $op Query operator (not an exact match to sql) * @param mixed $value * @param float $min * @param float $max * * @return null|string */ function whereClause(&$field, $op, $value, $min, $max) { if ($field['name'] =='start_date') { return( "pledge_civireport.contact_id NOT IN (SELECT distinct cont.id FROM civicrm_contact cont, civicrm_pledge pledge WHERE cont.id = pledge.contact_id AND YEAR (pledge.start_date) = $value AND pledge.is_test = 0 )" ); } return parent::whereClause($field, $op, $value, $min, $max); }