From: Chuck Hagenbuch Date: Wed, 15 Sep 2010 18:32:48 +0000 (-0400) Subject: Add JOIN for tag filtering X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=04858a3b2a3910ae9bb36d3155ee0f345a565a0b;p=horde.git Add JOIN for tag filtering Add WHERE clause for published filtering Fix missing arguments to getAssoc() --- diff --git a/jonah/lib/Driver/Sql.php b/jonah/lib/Driver/Sql.php index 64543597d..9d1c3d198 100644 --- a/jonah/lib/Driver/Sql.php +++ b/jonah/lib/Driver/Sql.php @@ -377,6 +377,7 @@ class Jonah_Driver_Sql extends Jonah_Driver 'stories.story_updated AS updated, ' . 'stories.story_read AS readcount ' . 'FROM jonah_stories AS stories ' . + 'JOIN jonah_stories_tags tags ON (stories.story_id = tags.story_id) ' . 'WHERE stories.channel_id=?'; $values = array($criteria['channel_id']); @@ -398,6 +399,9 @@ class Jonah_Driver_Sql extends Jonah_Driver $sql .= ' AND story_published <= ?'; $values[] = $criteria['published-max']->timestamp(); } + if (isset($criteria['published'])) { + $sql .= ' AND story_published IS NOT NULL'; + } // Apply tag filtering if (isset($criteria['tags'])) { @@ -868,7 +872,7 @@ class Jonah_Driver_Sql extends Jonah_Driver public function getTagIds($names) { $sql = 'SELECT t.tag_name, t.tag_id FROM jonah_tags as t WHERE t.tag_name IN(' . str_repeat('?,', count($names) - 1) . '?)'; - $tags = $this->_db->getAssoc($sql); + $tags = $this->_db->getAssoc($sql, false, $names); if ($tags instanceof PEAR_Error) { throw new Jonah_Exception($tags); }