當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tags::findFirst方法代碼示例

本文整理匯總了PHP中Tags::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tags::findFirst方法的具體用法?PHP Tags::findFirst怎麽用?PHP Tags::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tags的用法示例。


在下文中一共展示了Tags::findFirst方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTagByName

 public function getTagByName($name)
 {
     $tag = Tags::findFirst(['conditions' => 'name = :name:', 'bind' => ['name' => $name]]);
     if (null == $tag) {
         $tag = new Tags();
         $tag->name = $name;
         $tag->save();
     }
     return $tag;
 }
開發者ID:huoybb,項目名稱:movie,代碼行數:10,代碼來源:Tags.php

示例2: addTags

 /**
  * Adds tags to a post
  */
 public function addTags($tags)
 {
     foreach ($tags as $t) {
         $t = trim($t);
         $tag = Tags::findFirst(array("tag = '{$t}'"));
         if (!$tag) {
             $tag = new Tags();
             $tag->tag = $t;
             $tag->save();
         }
         $postTag = PostTags::findFirst(array("conditions" => "posts_id = ?1 AND tags_id = ?2", "bind" => array(1 => $this->id, 2 => $tag->id)));
         if (!$postTag) {
             $postTag = new PostTags();
             $postTag->posts_id = $this->id;
             $postTag->tags_id = $tag->id;
             $postTag->save();
         }
         unset($tag);
         unset($postTag);
     }
 }
開發者ID:gn0st1k4m,項目名稱:phalconBlog,代碼行數:24,代碼來源:Posts.php

示例3: Users

 $filter = new Phalcon\Filter();
 $user = new Users();
 $data = $request->getPost('tags', null, false);
 $image = Images::findFirst("id = '" . $id . "'");
 $tags = [];
 /**
  * Save each tag
  * This is done by:
  * 1) Getting/creating the tag
  * 2) Creating an imageTag
  * 3) Saving the imageTag
  */
 foreach ($data as $tagRow) {
     $name = $filter->sanitize($tagRow['name'], 'string');
     //Get tag if it exists already
     $tag = Tags::findFirst("name = '" . $name . "' AND category_id = '" . $tagRow['category_id'] . "'");
     if (!$tag) {
         $tag = new Tags();
     }
     $tag->name = $name;
     $tag->category_id = $tagRow['category_id'];
     //If the tag could not be saved, dump the error messages
     if (!$tag->save()) {
         echo 'could not save tag.';
         var_dump($tagRow);
         var_dump($tag->getMessages());
         $app->response->setStatusCode('500');
         $app->response->send();
     }
     $tag->refresh();
     //Create an imageTag for each tag
開發者ID:stumpdk,項目名稱:hack4dk_DR_images,代碼行數:31,代碼來源:index.php

示例4: getTag

 /**
  * @return Tags
  */
 public function getTag()
 {
     return Tags::findFirst($this->tag_id);
 }
開發者ID:huoybb,項目名稱:standard,代碼行數:7,代碼來源:Tagmetas.php

示例5: tag

 /**
  * @return Tags
  */
 public function tag()
 {
     return $this->make('tag', function () {
         return Tags::findFirst($this->tag_id);
     });
 }
開發者ID:huoybb,項目名稱:standard,代碼行數:9,代碼來源:Taggables.php

示例6: fetchWidgetData

 public function fetchWidgetData($view, $block = '')
 {
     $widgetData = array();
     $blockCfgKey = $block ? $view . '_' . $block : $view;
     $blockCfg = $this->_siteConfig['blockCfg'][$blockCfgKey];
     $blockNum = $this->_siteConfig['widgetCfg']['blockNum'];
     switch ($view) {
         case 'slider':
             //理財故事
         //理財故事
         case 'btslider':
             $widgetData[$block] = array('blockName' => $block, 'items' => $this->_siteConfig['slider'][$block]);
             break;
         case 'dailyword':
             $dailyword['title'] = '天天詞匯';
             $dailyword['word'] = Tags::findFirst(array("conditions" => "is_cidian = ?1", "bind" => array(1 => 1)))->toArray();
             $widgetData = $dailyword;
             break;
         case 'content':
             switch ($block) {
                 case 'node':
                     $content = TreeData::findFirst($this->_params['nid'])->toArray();
                     $content['content'] = htmlspecialchars_decode($content['content']);
                     $widgetData[$block]['content'] = $content;
                     break;
                 case 'tag':
                     $content = Tags::findFirst($this->_params['tid'])->toArray();
                     $content['content'] = htmlspecialchars_decode($content['description']);
                     $content['title'] = $content['name'];
                     $widgetData[$block]['content'] = $content;
                     break;
                 case 'static':
                     $static_content = TreeStruct::findFirst(array("conditions" => "pid = ?1", "bind" => array(1 => $this->_params['nid']), 'order' => 'lft asc'));
                     $content = array();
                     if ($static_content) {
                         $content['title'] = $static_content->TreeData->title;
                         $content['content'] = htmlspecialchars_decode($static_content->TreeData->content);
                     }
                     $widgetData[$block]['blockName'] = $block;
                     $widgetData[$block]['content'] = $content;
                     break;
                 default:
                     break;
             }
             break;
         case 'cidian':
             $cidianCloudNum = $this->_siteConfig['widgetCfg']['cidianCloudNum'];
             $tags = Tags::fetchCidiansCloud($cidianCloudNum);
             $widgetData = $tags;
             break;
         case 'hangqing':
         case 'lilv':
         case 'tool':
             break;
         case 'taglist':
             $taglist = array();
             $itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
             $start = ($this->_params['p'] - 1) * $itemPer;
             if ($this->_params['tagPrefix']) {
                 $conditions = 'pinyinPrefix="' . $this->_params['tagPrefix'] . '" and is_cidian=1';
             } else {
                 $conditions = 'is_cidian=1';
             }
             $taglist['items'] = Tags::find(array('conditions' => $conditions, 'order' => 'id desc', 'limit' => array('number' => $itemPer, 'offset' => $start)))->toArray();
             $totalTags = Tags::count($conditions);
             $params = array('total_rows' => $totalTags, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
             $pagerLib = new Pager($params);
             $pager = $pagerLib->show(3);
             $taglist['pager'] = $pager;
             //				echo '<pre>';print_r($taglist);echo '</pre>';
             $widgetData = $taglist;
             break;
         case 'taglist_header':
             $optRanges = array(97, 122);
             $options = array();
             $options[] = '0-9';
             for ($i = $optRanges[0]; $i <= $optRanges[1]; $i++) {
                 $options[] = chr($i);
             }
             $widgetData = $options;
             break;
         case 'list':
             switch ($block) {
                 case 'node':
                     $nodeLists = array();
                     $itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
                     $start = ($this->_params['p'] - 1) * $itemPer;
                     $temNodes = TreeStruct::find(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article'), 'limit' => array('number' => $itemPer, 'offset' => $start), 'order' => 'id desc'));
                     $nodes = array();
                     foreach ($temNodes as $key => $temNode) {
                         $treeData = $temNode->TreeData->toArray();
                         $nodes[$key] = $temNode->toArray();
                         $nodes[$key]['TreeData'] = $treeData;
                     }
                     $nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 1));
                     $totalNodes = TreeStruct::count(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article')));
                     $params = array('total_rows' => $totalNodes, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
                     $pagerLib = new Pager($params);
                     $pager = $pagerLib->show(3);
                     $nodeLists['title'] = $this->_params['node']->TreeData->title;
//.........這裏部分代碼省略.........
開發者ID:xujianjun,項目名稱:touzilicai,代碼行數:101,代碼來源:ControllerBase.php


注:本文中的Tags::findFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。