From 3d1cdb30833c4d000e8a01e7a771f5977678ba2a Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Fri, 28 May 2010 14:22:23 -0400 Subject: [PATCH] Simplify - only return the tag_names, we won't need the ids in this case. --- content/lib/Tagger.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/content/lib/Tagger.php b/content/lib/Tagger.php index f6c2d5ecf..2a54e4270 100644 --- a/content/lib/Tagger.php +++ b/content/lib/Tagger.php @@ -201,23 +201,21 @@ class Content_Tagger * content type_id * @return array An array in the form of: *
-     *      array('localobjectId' => array(array(tag_name, tag_id),
-     *                                     array(tag_name, tag_id)),
-     *            'anotherobjectid' => array(array(tag_name, tag_id),
-     *                                     array(tag_name, tag_id)))
+     *      array('localobjectId' => array('tagone', 'tagtwo'),
+     *            'anotherobjectid' => array('anothertag', 'yetanother'))
      * 
*/ public function getTagsByObjects($objects, $type) { $object_ids = $this->_objectManager->exists($objects, $type); - $sql = 'SELECT DISTINCT t.tag_id AS tag_id, tag_name, tagged.object_id FROM ' . $this->_t('tags') . ' AS t INNER JOIN ' . $this->_t('tagged') . ' AS tagged ON t.tag_id = tagged.tag_id AND tagged.object_id IN (' . str_repeat('?,', count($object_ids) - 1) . '?)'; + $sql = 'SELECT DISTINCT tag_name, tagged.object_id FROM ' . $this->_t('tags') . ' AS t INNER JOIN ' . $this->_t('tagged') . ' AS tagged ON t.tag_id = tagged.tag_id AND tagged.object_id IN (' . str_repeat('?,', count($object_ids) - 1) . '?)'; $tags = $this->_db->selectAll($sql, array_keys($object_ids)); $results = array(); foreach ($tags as $tag) { if (empty($results[$object_ids[$tag['object_id']]])) { $results[$object_ids[$tag['object_id']]] = array(); } - $results[$object_ids[$tag['object_id']]][] = array('tag_id' => $tag['tag_id'], 'tag_name' => $tag['tag_name']); + $results[$object_ids[$tag['object_id']]][] = $tag['tag_name']; } return $results; -- 2.11.0