/** * @param DB_DataObject $obj the recordset on which the select query will be executed */ public function getTagsArray($obj) { if (is_array($obj->_tagplugin_cache)) { return $obj->_tagplugin_cache; } if (empty($obj->tagplugin_cache)) { $tag = DB_DataObject::factory('tag'); $dbo = DB_DataObject::factory('tag_record'); $dbo->tagged_table = $obj->tableName(); $dbo->record_id = $obj->pk(); $tag->selectAdd(); $tag->selectAdd('tag.id,tag.strip'); $tag->joinAdd($dbo); $tag->selectAs($dbo, 'link_%s'); $tag->find(); $obj->tagplugin_cache = '|'; while ($tag->fetch()) { if (empty($tag->strip)) { continue; } $obj->tagplugin_cache .= $tag->strip . '|'; $obj->_tagplugin_cache[] = $tag->strip; } $db = $obj->getDatabaseConnection(); $query = sprintf('UPDATE %s SET tagplugin_cache=:cacheval where %s = :pkval', $db->quoteIdentifier($obj->tableName()), $db->quoteIdentifier($obj->pkName())); $sth = $db->prepare($query, array('text', 'text')); if (PEAR::isError($sth)) { throw new Exception($sth->getMessage() . ' HINT: check if your table has a tagplugin_cache field'); } $sth->execute(array('cacheval' => $obj->tagplugin_cache, 'pkval' => $obj->pk())); } $obj->_tagplugin_cache = explode('|', $obj->tagplugin_cache); return $obj->_tagplugin_cache; }