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


PHP Tag::save方法代码示例

本文整理汇总了PHP中Tag::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::save方法的具体用法?PHP Tag::save怎么用?PHP Tag::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tag的用法示例。


在下文中一共展示了Tag::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _test_should_store_zero_strings_as_intergers

 public function _test_should_store_zero_strings_as_intergers()
 {
     $Tag = new Tag(array('name' => 'Ticket #21'));
     $this->assertTrue($Tag->save());
     $this->assertEqual($Tag->get('score'), 100);
     $Tag->setAttributes(array('score' => '0'));
     $this->assertTrue($Tag->save());
     $Tag = $Tag->find($Tag->id);
     $this->assertIdentical($Tag->get('score'), 0);
 }
开发者ID:bermi,项目名称:akelos,代码行数:10,代码来源:type_casting.php

示例2: executeSaveTag

 public function executeSaveTag()
 {
     try {
         $parameters = $this->getRequest()->getParameterHolder()->getAll();
         if ($parameters['id']) {
             $obj = Document::getDocumentInstance($parameters['id']);
             $parent = Document::getParentOf($parameters['id']);
         } else {
             $obj = new Tag();
             $parent = Document::getDocumentInstance($parameters['parent']);
         }
         foreach ($parameters as $key => $value) {
             if (!(strpos($key, 'attr') === false)) {
                 $function = 'set' . str_replace('attr', '', $key);
                 $obj->{$function}($value);
             }
         }
         if (!$parameters['attrExclusive']) {
             $obj->setExclusive(0);
         }
         $obj->save(null, $parent);
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     PanelService::redirect('tag');
     exit;
 }
开发者ID:kotow,项目名称:work,代码行数:28,代码来源:actions.class.php

示例3: newTag

 /**
  * @param sfGuardUser $user
  * @param integer $element_id
  * @param string $name
  * @param string $type
  */
 public static function newTag($user, $element_id, $name, $type)
 {
     $tag = TagTable::getInstance()->findOneByNameAndUserId($name, $user->id);
     if (!$tag) {
         $tag = new Tag();
         $tag->setName(substr($name, 0, self::MAX_LENGTH));
         $tag->setUserId($user->id);
         $tag->save();
     }
     if ($type == 'decision') {
         $tagDecision = new TagDecision();
         $tagDecision->setDecisionId($element_id);
         $tagDecision->setTagId($tag->id);
         $tagDecision->save();
     } else {
         if ($type == 'release') {
             $tagRelease = new TagRelease();
             $tagRelease->setReleaseId($element_id);
             $tagRelease->setTagId($tag->id);
             $tagRelease->save();
         } else {
             $tagAlternative = new TagAlternative();
             $tagAlternative->setAlternativeId($element_id);
             $tagAlternative->setTagId($tag->id);
             $tagAlternative->save();
             Doctrine_Query::create()->delete('Graph')->where('decision_id = ?', $tagAlternative->Alternative->decision_id)->execute();
         }
     }
     return;
 }
开发者ID:sensorsix,项目名称:app,代码行数:36,代码来源:Tag.class.php

示例4: upgradeTo02

 /**
  * @return void
  */
 protected function upgradeTo02()
 {
     // Add Tag-column
     /* @var CDbCommand $cmd */
     $cmd = Yii::app()->db->createCommand();
     $cmd->addColumn('Tag', 'userId', 'integer NOT NULL');
     $cmd->addForeignKey('user', 'Tag', 'userId', 'User', 'id', 'CASCADE', 'CASCADE');
     // Refresh DB-Schema
     Yii::app()->db->schema->refresh();
     Tag::model()->refreshMetaData();
     // Set user-IDs
     foreach (Tag::model()->findAll() as $model) {
         // Collect User-IDs
         $userIds = array();
         foreach ($model->entries as $entry) {
             $userIds[$entry->userId] = $entry->userId;
         }
         // Save tag with user relation
         foreach ($userIds as $userId) {
             $tag = new Tag();
             $tag->name = $model->name;
             $tag->userId = $userId;
             $tag->save(false);
         }
         // Remove tag
         $model->delete();
     }
 }
开发者ID:humantech,项目名称:ppma,代码行数:31,代码来源:UpgradeController.php

示例5: savePostTags

 public static function savePostTags($postid, $tags)
 {
     $postid = (int) $postid;
     if (0 === $postid || empty($tags)) {
         return false;
     }
     if (is_string($tags)) {
         $tags = self::filterTagsArray($tags);
     }
     $count = 0;
     foreach ((array) $tags as $v) {
         $model = self::model()->findByAttributes(array('name' => $v));
         if ($model === null) {
             $model = new Tag();
             $model->name = $v;
             if ($model->save()) {
                 $count++;
             }
         }
         $row = app()->getDb()->createCommand()->select('id')->from(TABLE_POST_TAG)->where(array('and', 'post_id = :postid', 'tag_id = :tagid'), array(':postid' => $postid, ':tagid' => $model->id))->queryScalar();
         if ($row === false) {
             $columns = array('post_id' => $postid, 'tag_id' => $model->id);
             $count = app()->getDb()->createCommand()->insert(TABLE_POST_TAG, $columns);
             if ($count > 0) {
                 $model->post_nums = $model->post_nums + 1;
                 $model->save(true, array('post_nums'));
             }
         }
         unset($model);
     }
     return $count;
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:32,代码来源:Tag.php

示例6: createAndSaveRawModelWithManyToManyRelation

 public static function createAndSaveRawModelWithManyToManyRelation()
 {
     include_once __DIR__ . '/../scripts/tested_models.php';
     $car = new \Car();
     $car->nameCar = 'AcmeCar';
     $car->noteCar = '10';
     $car->idBrand = 1;
     $car->save();
     $tags = array();
     $tag1 = new \Tag();
     $tag1->libTag = 'Sport';
     $tag1->save();
     $tag2 = new \Tag();
     $tag2->libTag = 'Family';
     $tag2->save();
     $tag3 = new \Tag();
     $tag3->libTag = 'Crossover';
     $tag3->save();
     $tags[] = $tag1;
     $tags[] = $tag2;
     $tags[] = $tag3;
     $car->setTag($tags);
     $car->save();
     // create test
     $req = \PicORM\Model::getDataSource()->prepare('SELECT count(*) as nb FROM car_have_tag WHERE idCar = ?');
     $req->execute(array($car->idCar));
     $resultBDD = $req->fetch(\PDO::FETCH_ASSOC);
     return array(array($car, $tags, $resultBDD));
 }
开发者ID:peacq,项目名称:picorm,代码行数:29,代码来源:Model.php

示例7: afterSave

    public function afterSave()
    {
        $this->_deleteRels();

        $model_id = get_class($this->owner);

        if (isset($_POST[$model_id]['tags']))
        {
            foreach (explode(',', $_POST[$model_id]['tags']) as $tag_name)
            {
                $tag = Tag::model()->find("name = '{$tag_name}'");
                if (!$tag)
                {
                    $tag = new Tag();
                    $tag->name = $tag_name;
                    $tag->save();
                }

                $tag_rel = new TagRel();
                $tag_rel->tag_id    = $tag->id;
                $tag_rel->object_id = $this->owner->id;
                $tag_rel->model_id  = $model_id;
            }
        }
    }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:25,代码来源:TagBehavior.php

示例8: recordTags

 public static function recordTags($phrase, $model, $obj)
 {
     $tags = TagTools::splitPhrase($phrase);
     foreach ($tags as $settag) {
         $tag = new Tag();
         if ($model == "etime") {
             $modelTag = new EtimeTag();
         } else {
             $modelTag = new EventTag();
         }
         $tag->setTag($settag);
         $c = new Criteria();
         $c->add(TagPeer::NORMALIZED_TAG, $tag->getNormalizedTag());
         $tag_exists = TagPeer::doSelectOne($c);
         if (!$tag_exists) {
             $tag->save();
         } else {
             $tag = $tag_exists;
         }
         if ($model == "etime") {
             $modelTag->setEtime($obj);
         } else {
             $modelTag->setEvent($obj);
         }
         $modelTag->setTag($tag);
         $modelTag->save();
     }
     return true;
 }
开发者ID:soon0009,项目名称:EMS,代码行数:29,代码来源:TagTools.class.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user_id = Auth::id();
     $comment = Input::get('comment');
     $tags = Input::get('tagged_uid');
     $rating = Input::get('rating');
     $type = Input::get('media_type');
     $imdb_id = Input::get('imdb_id');
     $post = new Post();
     $post->user_id = $user_id;
     $post->type = $type;
     $post->imdb_id = $imdb_id;
     $post->rating = $rating;
     $post->comment = $comment;
     $post->save();
     if (sizeof($tags) > 0) {
         foreach ($tags as $tagged_uid) {
             $tag = new Tag();
             $tag->post_id = $post->id;
             $tag->user_tagging = $user_id;
             $tag->user_tagged = $tagged_uid;
             $tag->save();
         }
     }
     return Redirect::to('/media/' . $imdb_id);
 }
开发者ID:jcanver,项目名称:seenjump,代码行数:31,代码来源:PostController.php

示例10: add

 public static function add($id, $meta)
 {
     $desc = Description::create(['id' => $id, 'name' => $meta->name, 'market_name' => $meta->market_name ?: $meta->name, 'icon_url' => $meta->icon_url, 'icon_url_large' => isset($meta->icon_url_large) ? $meta->icon_url_large : '', 'name_color' => $meta->name_color ?: '000000']);
     if (!empty($meta->actions)) {
         foreach ($meta->actions as $idx => $action) {
             if ($action->name == 'Inspect in Game...') {
                 $desc->inspect_url_template = $action->link;
                 $desc->save();
                 break;
             }
         }
     }
     foreach ($meta->tags as $idx => $tag_data) {
         $tag = Tag::find('all', array('conditions' => array('category = ? AND category_name = ? AND internal_name = ? AND name = ?', $tag_data->category, $tag_data->category_name, $tag_data->internal_name, $tag_data->name)));
         if (empty($tag)) {
             $tag = new Tag(['category' => $tag_data->category, 'category_name' => $tag_data->category_name, 'internal_name' => $tag_data->internal_name, 'name' => $tag_data->name]);
             if (!$tag->is_valid()) {
                 $desc->delete();
                 return null;
             } else {
                 $tag->save();
             }
         } else {
             $tag = $tag[0];
         }
         if ($tag_data->category == 'Rarity') {
             $desc->name_color = $tag_data->color;
             $desc->save();
         }
         Descriptiontag::create(['description_id' => $desc->id, 'tag_id' => $tag->id]);
     }
     return $desc;
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:33,代码来源:Description.php

示例11: incrementCount

 /**
  * Private! Please do not call this function directly, just let the Tag library use it.
  * Increment count of tag by one. This function will create tag record if it does not exist.
  *
  * @param string $tagString
  */
 public static function incrementCount($tagString, $tagSlug, $count)
 {
     if ($count <= 0) {
         return;
     }
     $tag = Tag::where('slug', '=', $tagSlug)->first();
     if (!$tag) {
         $tag = new Tag();
         $tag->name = $tagString;
         $tag->slug = $tagSlug;
         $tag->suggest = false;
         $tag->save();
     }
     $tag->count = $tag->count + $count;
     $tag->save();
 }
开发者ID:leebivip,项目名称:laravel_cmp,代码行数:22,代码来源:TaggingUtil.php

示例12: createNew

 /**
  * @param String $tag
  * @return Tag
  */
 public function createNew($tag)
 {
     $tagInstance = new Tag();
     $tagInstance->name = $tag;
     $tagInstance->save();
     return $tagInstance;
 }
开发者ID:Sywooch,项目名称:noteapp,代码行数:11,代码来源:Tag.php

示例13: set_tags

 /**
  * set and add new tags to the post entity
  * @param string $val
  * @return array
  */
 public function set_tags($val)
 {
     if (!empty($val)) {
         $tagsArr = \Base::instance()->split($val);
         $tag_res = new Tag();
         $tags = array();
         // find IDs of known Tags
         $known_tags = $tag_res->find(array('title IN ?', $tagsArr));
         if ($known_tags) {
             foreach ($known_tags as $tag) {
                 $tags[$tag->_id] = $tag->title;
             }
             $newTags = array_diff($tagsArr, array_values($tags));
         } else {
             $newTags = $tagsArr;
         }
         // create remaining new Tags
         foreach ($newTags as $tag) {
             $tag_res->reset();
             $tag_res->title = $tag;
             $out = $tag_res->save();
             $tags[$out->_id] = $out->title;
         }
         // set array of IDs to current Post
         $val = array_keys($tags);
     }
     return $val;
 }
开发者ID:xfra35,项目名称:fabulog,代码行数:33,代码来源:post.php

示例14: registerUser

 /**
  * This function will create a new user object and return the newly created user object.
  *
  * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
  *
  * @return mixed
  */
 public function registerUser(array $userInfo, $userLanguage)
 {
     $user = \User::create($userInfo);
     //make the first user an admin
     if (\User::all()->count() <= 1) {
         $user->is_admin = 1;
     }
     // Trim trailing whitespace from user first and last name.
     $user->firstname = trim($user->firstname);
     $user->lastname = trim($user->lastname);
     $user->save();
     \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
     /* Add welcome note to user - create notebook, tag and note */
     //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
     $notebookCreate = new \Notebook();
     $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
     $notebookCreate->save();
     $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
     $tagCreate = new \Tag();
     $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
     $tagCreate->visibility = 0;
     $tagCreate->user_id = $user->id;
     $tagCreate->save();
     //$tagCreate->users()->attach($user->id);
     $noteCreate = new \Note();
     $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $notebookCreate->id;
     $noteCreate->save();
     $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     $noteCreate->tags()->sync([$tagCreate->id]);
     return $user;
 }
开发者ID:jinchen891021,项目名称:paperwork,代码行数:42,代码来源:UserRegistrator.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $tag = new Tag();
     $tag->name = Input::get('name');
     $tag->save();
     return Redirect::action('TagController@index')->with('flash_message', 'Your tag been added.');
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:12,代码来源:TagController.php


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