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


PHP Comment::hasError方法代码示例

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


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

示例1: create

 /**
  * create new thread
  * @param Comment $comment
  * @throws ValidationException
  */
 public function create(Comment $comment)
 {
     $this->validate();
     $comment->validate();
     if ($this->hasError() || $comment->hasError()) {
         throw new ValidationException('invalid thread or comment');
     }
     $db = DB::conn();
     $db->begin();
     $db->query('INSERT INTO thread SET title = ?, created = NOW()', array($this->title));
     $this->id = $db->lastInsertId();
     // write first comment at the same time
     $this->write($comment);
     $db->commit();
 }
开发者ID:ry-htr,项目名称:dietcake-sample,代码行数:20,代码来源:thread.php

示例2: edit

 public function edit(Comment &$comment)
 {
     $this->validate();
     $comment->validate();
     if ($this->hasError() || $comment->hasError()) {
         throw new ValidationException('Invalid thread or comment.');
     }
     $db = DB::conn();
     $db->begin();
     try {
         $db->query("UPDATE thread SET title=?, category_name=?,\n                last_modified=NOW() WHERE id=?", array($this->title, $this->category, $this->id));
         $comment->edit();
         $db->commit();
     } catch (PDOException $e) {
         $db->rollback();
     }
 }
开发者ID:renzosunico,项目名称:MyClassroom,代码行数:17,代码来源:thread.php

示例3: create

 /**
  * To create comment
  * @param $comment
  * @throws ValidationException
  **/
 public function create(Comment $comment)
 {
     $this->validate();
     $comment->validate();
     if ($this->hasError() || $comment->hasError()) {
         throw new ValidationException('invalid thread or comment');
     }
     $db = DB::conn();
     try {
         $db->begin();
         $db->insert('thread', array('title' => $this->title));
         $this->id = $db->lastInsertId();
         //write first comment at the same time
         $this->write($comment);
         $db->commit();
     } catch (ValidationException $e) {
         $db->rollback();
         throw $e;
     }
 }
开发者ID:LowellaMercurio,项目名称:board-1,代码行数:25,代码来源:thread.php

示例4: create

 /** 
  * Validate first the Thread & Comment.
  * If both hasError() -> throw Exception
  * Get title of Thread, Get Comment
  * Insert to the Database.
  * @param $comment
  */
 public function create(Comment $comment)
 {
     $this->validate();
     $comment->validate();
     if ($this->hasError() || $comment->hasError()) {
         throw new ValidationException('Invalid thread or comment');
     }
     $db = DB::conn();
     try {
         $db->begin();
         $params = array('user_id' => $this->user_id, 'title' => $this->title);
         $db->insert('thread', $params);
         $this->id = $db->lastInsertId();
         $comment->write($this->id);
         $db->commit();
     } catch (ValidationException $e) {
         $db->rollback();
         throw $e;
     }
 }
开发者ID:jeszytanada,项目名称:BoardJeszy,代码行数:27,代码来源:thread.php

示例5: glob

<?php

$picture = glob('bootstrap/img/users/' . $user->username . '.*');
if (isset($_SESSION['old_thread'])) {
    $old_thread = new Thread($_SESSION['old_thread']);
}
if (isset($_SESSION['old_comment'])) {
    $old_comment = new Comment($_SESSION['old_comment']);
}
?>

<?php 
if (isset($old_thread) && $old_thread->hasError() || isset($old_comment) && $old_comment->hasError()) {
    ?>
    <div class="row">
      <div class="col-xs-12 col-md-offset-2 col-md-8 col-lg-offset-2 col-lg-8s">
        <div class="alert alert-danger">
            <h4 class="alert-heading">
              <span class="glyphicon glyphicon-warning-sign"></span> Warning!
            </h4>
            <?php 
    if (!empty($old_thread->validation_errors['title']['length'])) {
        ?>
                <div><em>Title</em> must be between
                    <?php 
        encode_quotes($old_thread->validation['title']['length'][1]);
        ?>
 and
                    <?php 
        encode_quotes($old_thread->validation['title']['length'][2]);
        ?>
开发者ID:renzosunico,项目名称:MyClassroom,代码行数:31,代码来源:profile.php

示例6: Comment

<div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <h1 class="thread-title"><?php encode_quotes($thread->title) ?></h1>
    </div>
</div>

<?php 
    if(isset($_SESSION['old_comment'])) {
        $old_comment = new Comment($_SESSION['old_comment']);
    }
?>
<?php if(isset($old_comment) && $old_comment->hasError()): ?>
    <div class="row">
      <div class="col-xs-12">
        <div class="alert alert-danger">
            <h4 class="alert-heading">
                <span class="glyphicon glyphicon-warning-sign"></span> Warning!
            </h4>
            <?php if(!empty($old_comment->validation_errors['body']['length'])): ?>
                <div><em>Comment</em> must be between
                    <?php encode_quotes($old_comment->validation['body']['length'][1]) ?> and
                    <?php encode_quotes($old_comment->validation['body']['length'][2]) ?> characters in length.
                </div>
            <?php endif ?>
            <?php if(!empty($old_comment->validation_errors['body']['chars'])): ?>
                <div><em>Comment</em> cannot be spaces only.
                </div>
            <?php endif ?>
        </div>
      </div>
    </div>
开发者ID:renzosunico,项目名称:MyClassroom,代码行数:31,代码来源:view.php


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