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


PHP Skill::model方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $type = Type::model()->findAll();
     $skill = Skill::model()->findAll();
     $usr = User::model()->findbyPk(1);
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'rand()';
     $total = Portfolio::model()->count();
     $pages = new CPagination($total);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $port = Portfolio::model()->findAll($criteria);
     $this->render('index', array('type' => $type, 'port' => $port, 'pages' => $pages, 'skill' => $skill, 'usr' => $usr));
 }
开发者ID:syukrikhafidh,项目名称:appdefault,代码行数:15,代码来源:SiteController.php

示例2: setUpRelationalModel

 function setUpRelationalModel()
 {
     $parentDocs = array(array('username' => 'sam', 'job_title' => 'awesome guy'), array('username' => 'john', 'job_title' => 'co-awesome guy'), array('username' => 'dan', 'job_title' => 'programmer'), array('username' => 'lewis', 'job_title' => 'programmer'), array('username' => 'ant', 'job_title' => 'programmer'));
     $childDocs = array(array('name' => 'jogging'), array('name' => 'computers'), array('name' => 'biking'), array('name' => 'drinking'), array('name' => 'partying'), array('name' => 'cars'));
     $docsLinkedByDBRef = array(array('name' => 'python'), array('name' => 'java'), array('name' => 'php'), array('name' => 'lisp'), array('name' => 'C'), array('name' => 'Objective C'), array('name' => 'C++'), array('name' => 'ruby'));
     foreach (array(array('class' => 'Interest', 'data' => $childDocs), array('class' => 'Skill', 'data' => $docsLinkedByDBRef)) as $subgroup) {
         foreach ($subgroup['data'] as $doc) {
             $i = new $subgroup['class']();
             foreach ($doc as $k => $v) {
                 $i->{$k} = $v;
             }
             $this->assertTrue($i->save());
         }
     }
     // Lets make sure those child docs actually went in
     $skills = iterator_to_array(Skill::model()->find());
     $this->assertTrue(count($skills) > 0);
     $c = Interest::model()->find();
     $this->assertTrue($c->count() > 0);
     // Let's build an array of the all the _ids of the child docs
     $interest_ids = array();
     foreach ($c as $row) {
         $interest_ids[] = $row->_id;
     }
     // Create the users with each doc having the value of the interest ids
     $user_ids = array();
     foreach ($parentDocs as $doc) {
         $u = new User();
         foreach ($doc as $k => $v) {
             $u->{$k} = $v;
         }
         $u->interests = $interest_ids;
         //Let`s take random skill as primary for this user
         $primarySkill = $skills[array_rand($skills)]->_id;
         $u->mainSkill = MongoDBRef::create(Skill::model()->collectionName(), $primarySkill);
         //Now, lets pick array of secondary skills
         $allSecondarySkills = array();
         foreach (array_rand($skills, rand(3, 5)) as $secondarySkill) {
             if ($secondarySkill == $primarySkill) {
                 continue;
             }
             array_push($allSecondarySkills, MongoDBRef::create(Skill::model()->collectionName(), $skills[$secondarySkill]->_id));
         }
         $u->otherSkills = $allSecondarySkills;
         $this->assertTrue($u->save());
         $user_ids[] = $u->_id;
     }
     $interests = array_values(iterator_to_array($c));
     // Now 50^6 times re-insert each interest with a parnt user _id
     // So we have two forms of the document in interests, one without the parent user and one with
     for ($i = 0; $i < 50; $i++) {
         $randInt = rand(0, sizeof($interests) - 1);
         $row = $interests[$randInt];
         $randPos = rand(0, sizeof($user_ids) - 1);
         $row->i_id = $user_ids[$randPos];
         $row->setIsNewRecord(true);
         $row->_id = null;
         $row->setScenario('insert');
         $this->assertTrue($row->save());
     }
     // we will assume the set up was successful and we will leave it to further testing to see
     // whether it really was.
 }
开发者ID:kl0428,项目名称:admin,代码行数:63,代码来源:MongoDocumentTest.php

示例3: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Skill the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Skill::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:syukrikhafidh,项目名称:appdefault,代码行数:15,代码来源:SkillController.php


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