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


PHP Rating::createRow方法代码示例

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


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

示例1: computeprefsAction

 function computeprefsAction()
 {
     // Load the template
     $this->view->setFile("content", "computeprefs.xml");
     $this->view->setBlock("content", "MEMBER", "MEMBERS");
     $paperTbl = new Paper();
     $userTbl = new User();
     $ratingTbl = new Rating();
     // Loop on PC members
     $members = $userTbl->fetchAll("roles LIKE '%R%'");
     $i = 0;
     foreach ($members as $member) {
         $this->view->css_class = Config::CssCLass($i++);
         $member->putInView($this->view);
         // Loop on papers
         if (1 == 1) {
             $qPapers = "SELECT * FROM Paper";
         } else {
             // Loop on papers that match the reviewer's topics
             $qPapers = "SELECT p.* FROM (Paper p LEFT JOIN PaperTopic t ON id=id_paper), " . " UserTopic s " . " WHERE (p.topic=s.idTopic OR t.id_topic=s.idTopic) AND s.id_user='{$user->id}' ";
         }
         $comments = "";
         $rPapers = $this->zmax_context->db->query($qPapers);
         while ($p = $rPapers->fetch(Zend_Db::FETCH_OBJ)) {
             // instantiate a PaperRow object. Ok, not elegant, but easier
             $paper = $paperTbl->find($p->id)->current();
             $conflict = false;
             // Get the rate, if exists
             $rating = $ratingTbl->find($paper->id, $member->id)->current();
             if (!is_object($rating)) {
                 // OK, the preference is unset. Check whether there is a conflict
                 $rating = $ratingTbl->createRow();
                 $rating->idPaper = $paper->id;
                 $rating->id_user = $member->id;
                 $conflict = $paper->checkConflictWithuser($member, $comments);
                 if ($conflict) {
                     // Conflict! The default preference is 0
                     $rating->rate = 0;
                 } else {
                     // Check whether some topics match
                     if ($member->matchTopic($paper->topic)) {
                         // Match! The default preference is 3
                         $comments .= "Topic match with paper {$paper->id} ({$paper->title})<br/> ";
                         $rating->rate = 3;
                     } else {
                         $rating->rate = 2;
                     }
                 }
                 // OK, now save the rating
                 $rating->save();
             } else {
                 $comments = $this->zmax_context->texts->admin->conflicts_prefs_already_set;
             }
         }
         // Loop on papers
         $this->view->comments = $comments;
         $this->view->append("MEMBERS", "MEMBER");
     }
     // End of loop on users
     echo $this->view->render("layout");
 }
开发者ID:camilorivera,项目名称:INNOVARE,代码行数:61,代码来源:ChairController.php

示例2: addBid

 /**
  * Modify the bid of a reviewer of the paper
  */
 function addBid($idPaper, $rate)
 {
     $found = false;
     $bids = $this->findRating();
     foreach ($bids as $bid) {
         if ($bid->idPaper == $idPaper) {
             $bid->rate = $rate;
             $found = true;
             $bid->save();
         }
     }
     // Insert if not found
     if (!$found) {
         $ratingTbl = new Rating();
         $rating = $ratingTbl->createRow();
         $rating->idPaper = $idPaper;
         $rating->id_user = $this->id;
         $rating->rate = $rate;
         $rating->save();
     }
 }
开发者ID:camilorivera,项目名称:INNOVARE,代码行数:24,代码来源:UserRow.php


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