本文整理汇总了PHP中Tag::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::insert方法的具体用法?PHP Tag::insert怎么用?PHP Tag::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertNewTag
public static function insertNewTag($app_id, $name, PDO $con = null)
{
$row = array('app_id' => $app_id, 'name' => $name);
$tag = new Tag($row);
$tag->insert($con);
return $tag;
}
示例2: setTagsArray
public function setTagsArray(array $data)
{
// reset dei tag per semplificare lo script
ProductTag::model()->deleteAll('product=:p', array(':p' => $this->id));
// data attuale
$now = new DateTime();
$timestamp = $now->format('Y-m-d H-i-s');
// ricerca dei tag e creazione dei link
foreach ($data as $tagName) {
$tag = Tag::model()->find('name=:nm', array(':nm' => $tagName));
/** @var Tag $tag */
if ($tag == null) {
$tag = new Tag();
$tag->name = $tagName;
$tag->description = ucwords($tagName);
$tag->timestamp = $timestamp;
$tag->insert();
}
$productTag = ProductTag::model()->find('product=:p AND tag=:t', array(':p' => $this->id, ':t' => $tag->id));
/** @var ProductTag $productTag */
if ($productTag == null) {
$productTag = new ProductTag();
$productTag->product = $this->id;
$productTag->tag = $tag->id;
$productTag->insert();
}
}
}
示例3: create
public function create()
{
if (isset($_POST["tag"])) {
$tag = new Tag();
$tag->setTag($_POST["tag"]);
$result_e = $tag->insert();
}
$this->redirect("Tags", "index");
}
示例4: get_tag_id
public static function get_tag_id($tag)
{
$sql = sprintf("SELECT tag_id FROM tag WHERE tag='%s'", $tag);
$tag_id = db()->Get_Cell($sql);
if (!$tag_id) {
$new_tag = new Tag();
$new_tag->tag($tag);
$tag_id = $new_tag->insert();
}
return $tag_id;
}
示例5: updateTag
function updateTag($tags)
{
$tags = array_map(function ($t) {
return trim($t);
}, explode(',', $tags));
$tags = array_filter($tags, function ($t) {
return strlen($t) > 0;
});
foreach ($this->tags as $i => $tag) {
$key = array_search($tag->tag->name, $tags);
if (false === $key) {
$tag->tag->count = $tag->tag->count - 1;
if ($tag->tag->count > 0) {
$tag->tag->update();
} else {
$tag->tag->delete();
}
$tag->delete();
} else {
unset($tags[$key]);
}
//do not change tag
}
foreach ($tags as $i => $t) {
$tag = new Tag();
$post2tag = new Post2Tag();
$tag->reset()->eq('name', $t)->find();
if (!$tag->id) {
$tag->name = $t;
$tag->count = 1;
$tag->insert();
} else {
$tag->count = $tag->count + 1;
$tag->update();
}
$post2tag->tag_id = $tag->id;
$post2tag->post_id = $this->id;
$post2tag->insert();
}
return $this;
}
示例6: insertTags
public function insertTags($item, $tagString)
{
Zend_Registry::get('logger')->entering();
$tags = Tag::parseTags($tagString);
foreach ($tags as $tagName) {
Zend_Registry::get('logger')->debug("Got tagname: '{$tagName}'");
// Find or create new tag
$tags = new Tag();
$where = $this->_db->quoteInto('name = ?', $tagName);
$tag = $tags->fetchRow($where);
Zend_Registry::get('logger')->debug("Got tag: '{$tag->id}', '{$tag->name}'");
if ($tag->id) {
$tagId = $tag->id;
} else {
$row = array('name' => $tagName);
$tagId = $tags->insert($row);
}
// Create association
$this->_db->insert('tags_items', array('item_id' => $item->id, 'tag_id' => $tagId));
}
Zend_Registry::get('logger')->exiting();
}
示例7: create
/**
* Create a tag and save it.
*
* @param array $paramarray An associative array of tag fields
* @return Tag The new Tag object
**/
static function create($paramarray)
{
$tag = new Tag($paramarray);
$tag->insert();
return $tag;
}
示例8: saveTags
public function saveTags($tags)
{
foreach ($tags as $tag) {
Tag::insert(array('tag' => $tag));
}
return true;
}
示例9: addTags
/**
* Adds tags to a tagged object.
*
* @param array $tags array holding tag names
* @param Tagged $object object that should be tagged
*/
public function addTags($tags, Tagged $object, $languageID = 0)
{
$tagIDs = array();
foreach ($tags as $tag) {
if (empty($tag)) {
continue;
}
$tagID = Tag::test($tag, $languageID);
if (!$tagID) {
$tagID = Tag::insert($tag, $languageID);
}
$tagIDs[] = $tagID;
}
$tagIDs = array_unique($tagIDs);
$sql = "INSERT INTO\twcf" . WCF_N . "_tag_to_object\n\t\t\t\t\t(objectID, tagID, taggableID, time, languageID)\n\t\t\tVALUES ";
foreach ($tagIDs as $tagID) {
$sql .= "(" . $object->getObjectID() . ", " . $tagID . ", " . $object->getTaggable()->getTaggableID() . ", " . TIME_NOW . ", " . $languageID . "),";
}
$sql = StringUtil::substring($sql, 0, StringUtil::length($sql) - 1);
$result = WCF::getDB()->sendQuery($sql);
}