mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
3850d57417
commit
c9f081af94
@ -17,7 +17,7 @@ class GreaterThanFilter extends SearchFilter {
|
|||||||
return $query->where(sprintf(
|
return $query->where(sprintf(
|
||||||
"%s > '%s'",
|
"%s > '%s'",
|
||||||
$this->getDbName(),
|
$this->getDbName(),
|
||||||
Convert::raw2sql($this->getValue())
|
Convert::raw2sql($this->getDbFormattedValue())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,20 @@ abstract class SearchFilter extends Object {
|
|||||||
return $candidateClass . "." . $this->name;
|
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
|
* Traverse the relationship fields, and add the table
|
||||||
* mappings to the query object state.
|
* mappings to the query object state.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user