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


PHP Rating::insert方法代码示例

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


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

示例1: sendratingsAction

 public function sendratingsAction()
 {
     echo 'foo';
     $params = array('recipe_id' => $this->recipe->id, 'value' => $this->_getParam('value'));
     /*	Try and insert them into DB	*/
     try {
         $r = new Rating();
         $r->insert($params);
         /* Incease ratings counters */
         $this->db->update("users", array("ratings_count" => new Zend_Db_Expr("(ratings_count + 1)")), "id = " . $this->session->user['id']);
         $this->db->update("recipes", array("ratings_count" => new Zend_Db_Expr("(ratings_count + 1)")), "id = " . $params['recipe_id']);
         /*	If successful go back to last recipe		*/
         $this->_redirect('/recipe/view/recipe_id/' . $params['recipe_id']);
         exit;
     } catch (Exception $e) {
         /*	Broken constraints = throws exception. Display error and return to recipe		*/
         $this->log->debug($e->getMessage());
         $this->message->setNamespace('error');
         $this->message->addMessage('You have already rated this recipe.');
         $this->_redirect('/recipe/view/recipe_id/' . $params['recipe_id']);
     }
 }
开发者ID:vishaleyes,项目名称:cookingwithzend,代码行数:22,代码来源:AjaxController.php

示例2: Database

<?php

error_reporting(0);
session_start();
include "../config/database.class.php";
include "../objects/rating.class.php";
include "../objects/menuoption.class.php";
$database = new Database();
$db = $database->getConnection();
if (isset($_POST['add'])) {
    $updatedOption = new Rating($db);
    $updatedOption->Rating = $_POST['rating'];
    $updatedOption->Comment = $_POST['comment'];
    $updatedOption->Guest_Id = $_SESSION['id'];
    $updatedOption->MenuOption_Id = $_POST['menuitemid'];
    if ($updatedOption->insert() == true) {
        header("location:guest.php");
    } else {
        echo "<script>alert('There was an error adding this item');window.location = 'guest.php' </script>";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
开发者ID:nathanashton,项目名称:GuestBook,代码行数:30,代码来源:addrating.php

示例3: testGetValidRatingByTrail

 /**
  * test inserting a Rating and grabbing it from my sql
  */
 public function testGetValidRatingByTrail()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("rating");
     // create a new rating and insert it into my sql
     $rating = new Rating($this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_RATINGVALUE);
     $rating->insert($this->getPDO());
     //grab the data from mySQL and enforce the fields match expectations
     $pdoRatings = Rating::getRatingValueByTrailId($this->getPDO(), $this->trail->getTrailId());
     foreach ($pdoRatings as $pdoRating) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("rating"));
         $this->assertSame($pdoRating->getRatingValue(), $this->VALID_RATINGVALUE);
     }
 }
开发者ID:jmsaul,项目名称:open-trails,代码行数:17,代码来源:rating-test.php


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