From e07094adad56de548788226ccd252a2436f41e40 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 8 Jan 2009 04:12:54 +0000 Subject: [PATCH] ENHANCEMENT Added SQLQuery->filtersOnFK() (merged from branches/translatable in r64523, thanks wakeless!) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69895 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 98065acd8..46227deee 100755 --- a/core/model/SQLQuery.php +++ b/core/model/SQLQuery.php @@ -437,6 +437,17 @@ class SQLQuery extends Object { ); } + /** + * Checks whether this query is filtering on a foreign key, ie finding a has_many relationship + * + * @return boolean + */ + function filtersOnFK() { + return ($this->where && + (strpos($this->where[0], "ID` = ") || (strpos($this->where[0], "ID = ") > 0)) + ); + } + /// VARIOUS TRANSFORMATIONS BELOW /**