BUGFIX: Fixed SQLQuery::filtersOnID() for cases where a ClassName filter is inserted before the ID filter.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84093 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-08-10 04:36:17 +00:00
parent 50176c631b
commit 788b435821

View File

@ -392,11 +392,13 @@ class SQLQuery extends Object {
* @return boolean
*/
function filtersOnID() {
return (
$this->where
//&& count($this->where) == 1
&& preg_match('/^(.*\.)?("|`)?ID("|`)?\s?=/', $this->where[0])
);
$regexp = '/^(.*\.)?("|`)?ID("|`)?\s?=/';
// Sometimes the ID filter will be the 2nd element, if there's a ClasssName filter first.
if(isset($this->where[0]) && preg_match($regexp, $this->where[0])) return true;
if(isset($this->where[1]) && preg_match($regexp, $this->where[1])) return true;
return false;
}
/**