_tags = &$tags; } function &getTags() { if($this->_tags === NULL) { $this->_tags = &new FAArrayIterator(explode(",", $this->_get('tags'))); } return $this->_tags; } function getPlussedTags() { return $this->_getTagsSeparator('+'); } function getRawTags() { return $this->_getTagsSeparator(', '); } function save() { if($ret = parent::save()) { //-------------------------------------------- // Loop over all of the tags that exist. //-------------------------------------------- $sql = "INSERT INTO k4_group_tags (group_id,tag_id) VALUES "; $group_id = intval($this->getId()); $tag_ids = array(); //-------------------------------------------- // Create the parts of the SQL query to link the // tags and group. //-------------------------------------------- while($this->_tags->next()) { $tag = &$this->_tags->current(); $sql .= "(". $group_id .",?),"; $tag_ids[] = $tag->getId(); } $sql = substr($sql, 0, -1); //-------------------------------------------- // Link the tags to the group. //-------------------------------------------- $this->_dba->executeUpdate($sql, $tag_ids); } return $ret; } function _getTagsSeparator($sep) { $str = ''; $tags = &$this->getTags(); $tags->reset(); while($tags->next()) { $tag = &$tags->current(); $str .= $tag . $sep; } return substr($str, 0, (-1 * strlen($sep)) ); } } ?>