Exemplo n.º 1
0
    private function addMetaDataTag($title)
    {
        $title = trim($title);
        // check to see if the tag already exists
        $instance_id = $this->image_set->instance === null ? null : $this->image_set->instance->id;
        $sql = sprintf('select * from
			PinholeTag where lower(title) = lower(%1$s)
				and instance %2$s %3$s', $this->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper'));
        if (count($tags) > 0) {
            $tag_obj = $tags->getFirst();
        } else {
            $tag_obj = new PinholeTagDataObject();
            $tag_obj->setDatabase($this->db);
            $tag_obj->setInstance($this->image_set->instance);
            $tag_obj->title = $title;
            $tag_obj->save();
        }
        return $tag_obj;
    }