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


PHP Rating::delete方法代码示例

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


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

示例1: header

            header("location:comments.php");
        } else {
            header("location:guest.php");
        }
    } else {
        if ($_SESSION['accesslevel'] == 1) {
            echo "<script>alert('There was an error updating this item');window.location = 'comments.php' </script>";
        } else {
            echo "<script>alert('There was an error updating this item');window.location = 'guest.php' </script>";
        }
    }
}
if (isset($_POST['delete'])) {
    $updatedOption = new Rating($db);
    $updatedOption->Id = $_POST['id'];
    if ($updatedOption->delete() == true) {
        if ($_SESSION['accesslevel'] == 1) {
            header("location:comments.php");
        } else {
            header("location:guest.php");
        }
    } else {
        if ($_SESSION['accesslevel'] == 1) {
            echo "<script>alert('There was an error deleting this item');window.location = 'comments.php' </script>";
        } else {
            echo "<script>alert('There was an error deleting this item');window.location = 'guest.php' </script>";
        }
    }
}
?>
开发者ID:nathanashton,项目名称:GuestBook,代码行数:30,代码来源:editrating.php

示例2: actionSetMark

 /**
  * Set mark for the good by user
  * @param $good_id
  * @param $rate mark (1-5)
  */
 public function actionSetMark($good_id, $rate)
 {
     if (Yii::app()->user->isGuest) {
         echo 'you are not registered user';
         return;
     }
     $user = Yii::app()->user->id;
     $rating = Rating::model()->with(array('good', 'good.marksCount'))->findByAttributes(array('good_id' => $good_id, 'user_id' => $user));
     if (empty($rating)) {
         if ($rate == 'undefined') {
             return;
         }
         $rating = new Rating();
         $rating->good_id = $good_id;
         $rating->user_id = $user;
         $rating->value = $rate;
         if ($rating->save()) {
             $good = $rating->good;
             $good->rating = round($good->rating + ($rate * 100 - $good->rating) / ($good->marksCount + 1));
             $good->save();
             echo 'success';
         } else {
             echo 'fail saving';
         }
     } else {
         if ($rating->value != $rate) {
             if ($rate == 'undefined') {
                 echo 'rate deleted';
                 $rating->delete();
                 return;
             }
             $old_mark = $rating->value;
             $rating->value = $rate;
             if ($rating->save()) {
                 $good = $rating->good;
                 $good->rating = round($good->rating + ($rate * 100 - $old_mark * 100) / $good->marksCount);
                 $good->save();
                 echo 'success';
             } else {
                 echo 'fail saving';
             }
         } else {
             echo 'no need to change';
         }
     }
 }
开发者ID:rahmanjis,项目名称:yii-catalog,代码行数:51,代码来源:ReviewController.php

示例3: testDeleteValidRating

 /**
  * test creating a rating then deleting it
  */
 public function testDeleteValidRating()
 {
     $numRows = $this->getConnection()->getRowCount("rating");
     // create a new rating and insert it into mySQL
     $rating = new Rating($this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_RATINGVALUE);
     $rating->insert($this->getPDO());
     // delete the user from mysql
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("rating"));
     $rating->delete($this->getPDO());
     // grab the data from mysql and enforce the fields meet expectation;
     $pdoRating = Rating::getRatingByTrailIdAndUserId($this->getPDO(), $this->trail->getTrailId(), $this->user->getUserId());
     $this->assertNull($pdoRating);
     $this->assertSame($numRows, $this->getConnection()->getRowCount("rating"));
 }
开发者ID:jmsaul,项目名称:open-trails,代码行数:17,代码来源:rating-test.php

示例4: Rating

<?
require_once('classes/Rating.php');
require_once('classes/Text.php');
$recipe_id = $_REQUEST['recipe_id'];
$value = $_REQUEST['rating'];
$comment = $_REQUEST['comment'];
$rating = Rating::getForRecipeAndUser($recipe_id);
if ($rating == NULL && $value > 0) {
  $rating = new Rating();
  $rating->recipe_id = $recipe_id;
}
if ($value < 0 && $rating != NULL) {
  $rating->delete();
}
if ($value > 0) {
  $rating->value = $value;
  $rating->comment = $comment;
  $rating->save();
}
echo 'OK';//Text::getText('ThankYou');
?>
开发者ID:elecnix,项目名称:smellyfish,代码行数:21,代码来源:rate.php

示例5: vote

 public function vote($userId, $photoId, $rating)
 {
     $oldRating = Rating::loadRating($userId, $photoId);
     if ($oldRating != null) {
         $oldRating->delete();
     }
     if ($rating > 0) {
         $newRating = new Rating(array('user_id' => $userId, 'photo_id' => $photoId, 'rating' => $rating));
         $newRating->store();
         $votes = $this->userRatings($userId);
         if ($votes['total_votes'] > $this->numberVotes) {
             $newRating->delete();
             if ($oldRating != null) {
                 $oldRating->store();
             }
             return false;
         } else {
             return true;
         }
     } else {
         return true;
     }
 }
开发者ID:dpecos,项目名称:photocontest,代码行数:23,代码来源:Contest.class.php


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