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