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


PHP Review::getErrors方法代碼示例

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


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

示例1: array

?>

<h2>It should create a valid Review object when all input is provided</h2>
<?php 
$validTest = array("firstName" => "Kay", "lastName" => "Robbins", "submissionID" => "R3023", "score" => "5", "review" => "This was a great presentation");
$s1 = new Review($validTest);
echo "The object is: {$s1}<br>";
$test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>';
echo $test1;
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>';
echo $test2;
?>

<h2>It should extract the parameters that went in</h2>
<?php 
$props = $s1->getParameters();
print_r($props);
?>

<h2>It should have an error when the first name contains invalid characters</h2>
<?php 
$invalidTest = array("firstName" => "krobbins\$");
$s1 = new Review($invalidTest);
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for firstName is: " . $s1->getError('firstName') . "<br>";
echo "The object is: {$s1}<br>";
?>
</body>
</html>
開發者ID:bennilyn,項目名稱:examples,代碼行數:30,代碼來源:Review_tests.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Review();
     if (isset($_POST['rating1'], $_POST['product_id'])) {
         $rId = $this->addRate($_POST['rating1'], $_POST['product_id']);
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['review_title'])) {
         $model->review_title = $_POST['review_title'];
         $model->review_content = $_POST['review_content'];
         $model->product_id = $_POST['product_id'];
         //echo $id; die();
         //                        $ratingIdfromSaveRating=new CHttpSession;
         //                        $ratingIdfromSaveRating->open();
         if ($rId) {
             $model->rating_id = $rId;
             // strip_tags($ratingIdfromSaveRating['rating_id']);
             $model->user_id = Yii::app()->user->user_id;
             //$model->attributes=$_POST['Review'];
             if ($model->save()) {
                 // echo var_dump($model); die();
             } else {
                 die(var_dump($model->getErrors()));
             }
             //echo 'not in'; die();
             //				$this->redirect(array('view','id'=>$model->review_id));
         }
     }
     $this->render('create', array('model' => $model, 'productId' => $model->product_id));
 }
開發者ID:indresh90,項目名稱:utopeen_webpeoduct,代碼行數:31,代碼來源:ReviewController.php


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