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


PHP Collection::model方法代码示例

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


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

示例1: run

 public function run()
 {
     $ids = array_reverse(Yii::app()->{$this->_type}->getPositions());
     $totalCount = count($ids);
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.id', $ids);
     if (!empty($ids)) {
         $criteria->order = 'FIELD(t.id, ' . implode(',', $ids) . ')';
     }
     $collections = Collection::model()->published()->with('series:published')->findAll();
     foreach ($collections as $collectionKey => &$collection) {
         $seriesArr = $collection->series;
         foreach ($seriesArr as $seriesKey => $series) {
             $series->goods = Good::model()->published()->series($series->id)->findAll($criteria);
             if (empty($series->goods)) {
                 unset($seriesArr[$seriesKey]);
             }
         }
         $collection->series = $seriesArr;
         if (empty($collection->series)) {
             unset($collections[$collectionKey]);
         }
     }
     $this->render($this->view, array('collections' => $collections));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:25,代码来源:TotalFavoriteWidget.php

示例2: loadModel

 public function loadModel($id)
 {
     if (($model = Collection::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:7,代码来源:CollectionBackendController.php

示例3: run

 public function run()
 {
     $this->collectionId = (int) $this->collectionId;
     $collection = Collection::model()->published()->with(array('series' => array('scopes' => array('published'), 'order' => 'series.sort ASC')))->findByPk($this->collectionId);
     if (!$collection) {
         return;
     }
     $this->render($this->view, array('collection' => $collection, 'title' => $this->title, 'seriesView' => $this->seriesView));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:9,代码来源:CollectionWidget.php

示例4: actionCollection

 public function actionCollection($alias)
 {
     $collection = Collection::model()->published()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'series' => array('scopes' => 'published', 'order' => 'series.sort ASC')))->find('t.alias = :alias', array(':alias' => $alias));
     if (!$collection) {
         throw new CHttpException(404);
     }
     $this->currentCollection = $collection;
     $this->render('collection', array('model' => $collection));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:9,代码来源:CatalogController.php

示例5: actionIndex

 public function actionIndex()
 {
     $needing_id = $_GET['id'];
     //需求不复杂使用ar
     //需求复杂可用dao(cdbcommand)
     //查询条件多用cdbcreteria类
     $needing = new Needing();
     $info = $needing->find('id=:id', array(':id' => $needing_id));
     //收藏
     $collection = Collection::model()->count('user_id=:user_id and needing_id=:cat_id', array(':user_id' => Yii::app()->user->id, ':cat_id' => $needing_id));
     //验证是否已参与需求
     $needing_gotAll = NeedingPre::model()->findAll('needing_id=:needing_id', array(':needing_id' => $needing_id));
     $needing_gotCheck = NeedingPre::model()->count('needing_id=:needing_id and username=:username', array(':needing_id' => $needing_id, ':username' => Yii::app()->user->name));
     //需求是否已托管
     $needing_tuoguan = NeedingGet::model()->find('needing_id=:needing_id', array(':needing_id' => $needing_id));
     $this->render('index', array('needing' => $info, 'collect_num' => $collection, 'needing_got' => $needing_gotCheck, 'needing_gotAll' => $needing_gotAll, 'needing_tuoguan' => $needing_tuoguan, 'needing_reply' => ''));
 }
开发者ID:shunwusong,项目名称:timer,代码行数:17,代码来源:DefaultController.php

示例6: findByAlias

 public function findByAlias()
 {
     return Collection::model()->findByAttributes(array('alias' => $this->alias));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:4,代码来源:Collection.php

示例7: getCollectionList

 public function getCollectionList()
 {
     return CHtml::listData(Collection::model()->findAll(), 'id', 'title');
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-decor,代码行数:4,代码来源:Series.php

示例8: newAlbum

 private function newAlbum()
 {
     //check if this is an album or collection
     //will also check if is a legall request, and if isn't, will throw an exception and stop
     $isCollection = self::isCollection();
     $models = $isCollection ? Collection::model()->findAll() : Album::model()->findAll();
     //if we haven't set a pid manually, we will set first free pid
     if (!$this->pid) {
         $max = 0;
         for ($i = 0; $i < 2; $i++) {
             $testmodel = $i === 0 ? new Album() : new Collection();
             $criteria = new CDbCriteria();
             $criteria->select = 'max(pid) AS pid';
             $row = $testmodel->model()->find($criteria);
             $max = $max < $row['pid'] ? $row['pid'] : $max;
         }
         //if is first created albums or collections, we set $this->pid to 1;
         $this->pid = $max ? (int) $max + 1 : 1;
         $max;
     }
     $arrModelsNames = array();
     foreach ($models as $m => $detail) {
         $trs = unserialize($detail['translations']);
         $name = $trs['name'][$this->lang->default];
         $arrModelsNames[] = $name;
     }
     $modelNameTranslations = array();
     $modelDescriptionTranslations = array();
     $albumName = '';
     foreach ($this->lang->all as $key => $language) {
         $name = self::purifiedTtext($_POST['newAlbumName_' . $language]);
         $name = $name ? $name : $this->tr('noName');
         $description = self::purifiedTtext($_POST['newAlbumDescription_' . $language]);
         $description = $description ? $description : $this->tr('noDescription');
         if (count($arrModelsNames)) {
             $p = explode(' ', $name);
             $last = $p[count($p) - 1];
             $name = is_numeric($last) ? self::firstFreeNameIndex($arrModelsNames, $name, $last) : ($name = self::firstFreeNameIndex($arrModelsNames, $name));
         }
         $modelNameTranslations[$language] = $name;
         $modelDescriptionTranslations[$language] = $description;
         $albumName .= ' ' . strtolower($name);
     }
     $translationsArr = array('name' => $modelNameTranslations, 'description' => $modelDescriptionTranslations);
     $model = $isCollection ? new Collection() : new Album();
     $model->pid = $this->pid;
     $model->url = $this->getUrlRouteStructure();
     $model->translations = serialize($translationsArr);
     $model->author = Yii::app()->user->name;
     $model->tags = self::tags($albumName);
     if (!$model->save()) {
         throw new Exception('fbgallery - newAlbum - ' . $this->tr('cantSave'));
     } else {
         if (!isset($_POST['isCollection'])) {
             self::createFoldersStructure();
         }
     }
 }
开发者ID:hipogea,项目名称:zega,代码行数:58,代码来源:operations.php

示例9: run

 public function run()
 {
     $budget = Collection::model()->findAllByAttributes(array('type' => Collection::BUDGET));
     $this->render('actionbar', array('budget' => $budget));
 }
开发者ID:limmer3,项目名称:instagress,代码行数:5,代码来源:HomeActionBar.php

示例10: getInfo

 protected function getInfo($from, $pid, $infoType)
 {
     $model = $from === 'album' ? Album::model()->find(array('condition' => "pid='{$pid}'")) : Collection::model()->find(array('condition' => "pid='{$pid}'"));
     $trs = unserialize($model->translations);
     $info = $trs[$infoType][$this->lang->active];
     if (!$info) {
         $info = $trs[$infoType][$this->lang->default];
     }
     return $info;
 }
开发者ID:hipogea,项目名称:zega,代码行数:10,代码来源:Collect.php

示例11: setPid

 protected function setPid()
 {
     //step 1:
     //create standard url using actual url
     $thisUrl = $this->getUrlRouteStructure();
     //chech if page is album
     //compare actual url route with routes from Album model
     $album = Album::model()->find(array('condition' => "url='{$thisUrl}'"));
     if ($album) {
         $this->pid = $album->pid;
         return;
     }
     //chech if page is collection
     $collection = Collection::model()->find(array('condition' => "url='{$thisUrl}'"));
     if ($collection) {
         $this->pid = $collection->pid;
         return;
     }
     //there isn't any album or collection for this page
     //if is visitor, there isn't necessary to generate next pid, we set it to 0;
     if (!$this->levelAccess) {
         $this->pid = 0;
         return;
     }
 }
开发者ID:hipogea,项目名称:zega,代码行数:25,代码来源:fbgallery.php


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