当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::insert方法代码示例

本文整理汇总了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;
 }
开发者ID:kzfk,项目名称:emlauncher,代码行数:7,代码来源:Tag.php

示例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();
         }
     }
 }
开发者ID:KuRLiC,项目名称:PHPTest,代码行数:28,代码来源:Product.php

示例3: create

 public function create()
 {
     if (isset($_POST["tag"])) {
         $tag = new Tag();
         $tag->setTag($_POST["tag"]);
         $result_e = $tag->insert();
     }
     $this->redirect("Tags", "index");
 }
开发者ID:Magicvan,项目名称:simple_mvc,代码行数:9,代码来源:TagsController.php

示例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;
 }
开发者ID:rtoews,项目名称:meocracy,代码行数:11,代码来源:class.tag.php

示例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;
 }
开发者ID:bephp,项目名称:blog,代码行数:41,代码来源:model.php

示例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();
 }
开发者ID:josephholsten,项目名称:swaplady,代码行数:22,代码来源:Item.php

示例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;
 }
开发者ID:anupom,项目名称:my-blog,代码行数:12,代码来源:tag.php

示例8: saveTags

 public function saveTags($tags)
 {
     foreach ($tags as $tag) {
         Tag::insert(array('tag' => $tag));
     }
     return true;
 }
开发者ID:awidarto,项目名称:tmadminflat,代码行数:7,代码来源:AdminController.php

示例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);
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:27,代码来源:TagEngine.class.php


注:本文中的Tag::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。