当前位置: 首页>>代码示例>>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;未经允许,请勿转载。