From 872b24003b97c1296e99739ce163cbf5c076bb6f Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 27 Aug 2008 05:16:44 +0000 Subject: [PATCH] ENHANCEMENT: wakeless - Added SQLQuery::filtersOnID() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61618 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SQLQuery.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/model/SQLQuery.php b/core/model/SQLQuery.php index 06145c556..3f1d64b42 100755 --- a/core/model/SQLQuery.php +++ b/core/model/SQLQuery.php @@ -435,6 +435,17 @@ class SQLQuery extends Object { return DB::query($this->sql()); } + /** + * Checks whether this query is for a specific ID in a table + * + * @return boolean + */ + function filtersOnID() { + return ($query->where && count($query->where) == 1 && + (strpos($query->where[0], ".`ID` = ") || strpos($query->where[0], ".ID = ") || strpos($query->where[0], "ID = ") ) + ); + } + /// VARIOUS TRANSFORMATIONS BELOW /**