本文整理汇总了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");
}
示例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();
}
}