當前位置: 首頁>>代碼示例>>PHP>>正文


PHP comment::getComments方法代碼示例

本文整理匯總了PHP中comment::getComments方法的典型用法代碼示例。如果您正苦於以下問題:PHP comment::getComments方法的具體用法?PHP comment::getComments怎麽用?PHP comment::getComments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在comment的用法示例。


在下文中一共展示了comment::getComments方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionView

 /**
  * Displays a single Items model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $commentsData = comment::getComments($id);
     $model = $this->findModel($id);
     $newComment = new Comment();
     $addToBasket = new basket();
     $description = new Description();
     $description->find()->where(['item_id' => $id])->all();
     $itemRating = ItemsRating::findOne($id);
     if ($model->count == 0) {
         Yii::$app->db->createCommand(" UPDATE `items` SET items.is_aviable=0 WHERE items.id =" . $id)->execute();
     } else {
         if (!Yii::$app->user->isGuest) {
             $uid = Yii::$app->user->identity->getId();
             $get_user = \dektrium\user\models\User::getUser($uid)->getModels()[0]['username'];
             if (isset($_POST['Comment'])) {
                 //            print_r($_POST['Comment']['text']);
                 $newComment = new Comment();
                 $newComment->author = $get_user;
                 $newComment->item_id = $id;
                 $newComment->user_id = $uid;
                 $newComment->date = date("Y-m-d h:i:s");
                 $newComment->text = $_POST['Comment']['text'];
                 $newComment->save();
             }
             if (isset($_POST['Basket'])) {
                 if ($model->is_aviable) {
                     if ($_POST['Basket']['count'] <= $model->count) {
                         $addToBasket = new Basket();
                         $have = $addToBasket->find()->where(['item_id' => $id, 'user_id' => $uid])->all();
                         if (!$have) {
                             $addToBasket->item_id = $id;
                             $addToBasket->user_id = $uid;
                             $addToBasket->name = $model->name;
                             $addToBasket->price = $model->price;
                             $addToBasket->count = $_POST['Basket']['count'];
                             $addToBasket->sum = $model->price * $_POST['Basket']['count'];
                             $addToBasket->save();
                         }
                     }
                 }
                 return $this->redirect(['view', 'id' => $id]);
             }
         }
     }
     return $this->render('view', ['model' => $model, 'commentsData' => $commentsData, 'newComment' => $newComment, 'itemRating' => $itemRating, 'addToBasket' => $addToBasket, 'description' => $description]);
 }
開發者ID:koakumasd,項目名稱:shop,代碼行數:52,代碼來源:ItemsController.php

示例2: session_start

<?php 
session_start();
if (isset($_SESSION['user'])) {
    $temp = $_SESSION['user'];
} else {
    header("Location: ../views/signinPage.php?message=" . urlencode("Login again!"));
}
?>

<?php 
require_once "../models/comment.php";
$rs = comment::getComments($_REQUEST['imgId']);
if ($rs == false) {
    echo "No Comments are given!";
} else {
    foreach ($rs as $row) {
        echo '"' . $row['commentstr'] . '" <i>by</i> <strong>' . $row['username'] . '</strong> <br>';
    }
}
?>
					
開發者ID:annjanu,項目名稱:PhotoShare,代碼行數:20,代碼來源:loadComments.php

示例3: intval

<?php

require "../includes/conf.inc.php";
require "../includes/functions.inc.php";
$postId = intval($_GET['id']);
$post = post::view($postId, 1);
if ($post == false) {
    die($e);
}
$comments = comment::getComments($postId);
if ($comments == false) {
    die($e);
}
if ($comments != 'empty') {
    $seeOlder = comment::checkOldComments($postId);
    if ($seeOlder == false) {
        $seeOlder = '';
    }
}
/*$likeObj = new like();
	$likeResult = $likeObj->getLikes($postId);
	if($likeResult == false){
		die($e);
	}

	if(isset($_SESSION['userLogin'])){
		$checkLike = $likeObj->checkLike($postId,$_SESSION['userId']);
		if($checkLike == false){
			die($e);
		} else if($checkLike == "liked"){
			$likeStatus = 'Unlike';
開發者ID:amriterry,項目名稱:ptn,代碼行數:31,代碼來源:index.php


注:本文中的comment::getComments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。