From 6a649447127b97bd63e53807e841a1e60e9470d4 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Wed, 6 May 2009 11:43:18 -0400 Subject: [PATCH] Check for an existing WHERE clause --- content/lib/Tagger.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/lib/Tagger.php b/content/lib/Tagger.php index 973b9b298..5d2887edd 100644 --- a/content/lib/Tagger.php +++ b/content/lib/Tagger.php @@ -240,6 +240,7 @@ class Content_Tagger } elseif (isset($args['userId'])) { $args['userId'] = current($this->_userManager->ensureUsers($args['userId'])); $sql = 'SELECT DISTINCT t.tag_id AS tag_id, tag_name FROM ' . $this->_t('tagged') . ' AS tagged INNER JOIN ' . $this->_t('tags') . ' AS t ON tagged.tag_id = t.tag_id WHERE tagged.user_id = ' . (int)$args['userId']; + $haveWhere = true; } elseif (isset($args['typeId'])) { $args['typeId'] = current($this->_typeManager->ensureTypes($args['typeId'])); $sql = 'SELECT DISTINCT t.tag_id AS tag_id, tag_name FROM ' . $this->_t('tagged') . ' AS tagged INNER JOIN ' . $this->_t('objects') . ' AS objects ON tagged.object_id = objects.object_id AND objects.type_id = ' . (int)$args['typeId'] . ' INNER JOIN ' . $this->_t('tags') . ' AS t ON tagged.tag_id = t.tag_id'; @@ -255,7 +256,7 @@ class Content_Tagger if (isset($args['q']) && strlen($args['q'])) { // @TODO tossing a where clause in won't work with all query modes - $sql .= ' WHERE tag_name LIKE ' . $this->_db->quoteString($args['q'] . '%'); + $sql .= (!empty($haveWhere) ? ' AND' : ' WHERE') . ' tag_name LIKE ' . $this->_db->quoteString($args['q'] . '%'); } if (isset($args['limit'])) { @@ -345,6 +346,7 @@ class Content_Tagger * limit Maximum number of objects to return. * offset Offset the results. Only useful for paginating, and not recommended. * tagId Return objects related through one or more tags. + * notTagId Don't return objects tagged with one or more tags. * typeId Only return objects with a specific type. * objectId Return objects with the same tags as $objectId. * -- 2.11.0