APICHANGE: introduce SearchFilter::getDbFormattedValue() and GreateThanFilter will used this method to make the qurey so that it can apply to a field that input format is different that its db format, such as CalendarDateField.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65742 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Normann Lou 2008-11-12 23:39:07 +00:00
parent 3850d57417
commit c9f081af94
2 changed files with 15 additions and 1 deletions

View File

@ -17,7 +17,7 @@ class GreaterThanFilter extends SearchFilter {
return $query->where(sprintf(
"%s > '%s'",
$this->getDbName(),
Convert::raw2sql($this->getValue())
Convert::raw2sql($this->getDbFormattedValue())
));
}

View File

@ -94,6 +94,20 @@ abstract class SearchFilter extends Object {
return $candidateClass . "." . $this->name;
}
/**
* Return the value of the field as processed by the DBField class
*
* @return string
*/
function getDbFormattedValue() {
// SRM: This code finds the table where the field named $this->name lives
// Todo: move to somewhere more appropriate, such as DataMapper, the magical class-to-be?
$candidateClass = $this->model;
$dbField = singleton($this->model)->dbObject($this->name);
$dbField->setValue($this->value);
return $dbField->RAW();
}
/**
* Traverse the relationship fields, and add the table
* mappings to the query object state.