+ $query_str = "
+ SELECT p.id, p.name, p.time, p.directory_path, p.description
+ FROM photos p
+ ";
+
+ /* if show_tags is set, only return details for photos which
+ are specified to be shown
+ */
+ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) {
+ $query_str.= "
+ INNER JOIN photo_tags pt
+ ON p.id=pt.photo_id
+ INNER JOIN tags t
+ ON pt.tag_id=t.id
+ WHERE p.id='". $idx ."'
+ AND t.name IN (
+ ";
+ foreach($this->cfg->show_tags as $tag) {
+ $query_str.= "'". $tag ."',";
+ }
+ $query_str = substr($query_str, 0, strlen($query_str)-1);
+ $query_str.= ")";
+ }
+ else {
+ $query_str.= "
+ WHERE p.id='". $idx ."'
+ ";
+ }
+
+ $result = $this->db->db_query($query_str);