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