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


PHP Comment::setAuthor方法代码示例

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


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

示例1: loadAll

 /**
  * @return array
  */
 public static function loadAll()
 {
     $dbWrapper = new DatabaseWrapper();
     $connection = $dbWrapper->getConnection();
     $query = "SELECT * FROM temos;";
     $temos = [];
     foreach ($connection->query($query) as $row) {
         $tema = new Tema($connection);
         $tema->setId($row['id']);
         $tema->setDate($row['subject_date']);
         $tema->setName($row['name']);
         $query = 'SELECT * FROM comments INNER JOIN temos ON comments.subjectId = ' . $row['id'] . " AND temos.id = " . $row['id'] . ";";
         $comments = [];
         foreach ($connection->query($query) as $i) {
             $comment = new Comment($connection);
             $comment->setId($i['id']);
             $comment->setsubjectId($i['subjectId']);
             $comment->setText($i['text']);
             $comment->setDate($i['date']);
             $comment->setAuthor($i['author']);
             $comments[] = $comment;
         }
         foreach ($comments as $comment) {
             $tema->setComments($comment);
         }
         $temos[] = $tema;
     }
     return $temos;
 }
开发者ID:einorler,项目名称:DB-namu-darbai,代码行数:32,代码来源:Tema.php

示例2: controlerJob

 public function controlerJob($maincont)
 {
     if ($maincont->isLoggued()) {
         /*$_POST["author"]="gg42";
         		$_POST["body"]="move Ur body4242";
         		$_POST["published"]="1";
         		$_POST["postid"]="2";
         		$_POST["id"]=3;
         		
         		$_SESSION["backmod"]="comment";
         		$_SESSION["backact"]="admin";*/
         if (isset($_POST["id"])) {
             $p = new Comment($_POST["id"]);
             $p->setAuthor($_POST["author"]);
             $p->setBody($_POST["body"]);
             //$p->setHour(date("h:i:s"));
             //$p->setDate(date("Y-m-d"));
             $p->setPublished($_POST["published"]);
             $p->setPostid($_POST["postid"]);
         }
         $maincont->goModule("comment", "admin");
         //$maincont->goModule($_SESSION["backmod"],$_SESSION["backact"]);
     } else {
         $maincont->goModule("admin", "loginform");
     }
 }
开发者ID:rogerwilko,项目名称:Yet-Another-Blog,代码行数:26,代码来源:controler.php

示例3: comment

function comment(array $articleLangs = array())
{
    $comment = new Comment();
    $comment->setAuthor(author('niko'));
    $comment->content = 'Booh.';
    $comment->setArticle(article($articleLangs));
    return $comment;
}
开发者ID:jeremyb,项目名称:akDoctrineTemplateCacheInvaliderPlugin,代码行数:8,代码来源:akDoctrineCacheUriResolverTest.php

示例4: add

 /**
  * Action to adds a comment to a post
  *
  * This method should only be called via HTTP POST.
  *
  * The user of the comment is taken from the {@link BaseController::currentUser}
  * property.
  * The expected HTTP parameters are:
  * <ul>
  * <li>id: Id of the post (via HTTP POST)</li>
  * <li>content: Content of the comment (via HTTP POST)</li>
  * </ul>
  *
  * The views are:
  * <ul>
  * <li>posts/view?id=post: If comment was successfully added of, 
  * or if it was not validated (via redirect). Includes these view variables:</li>
  * <ul>   
  *  <li>errors (flash): Array including per-field validation errors</li>
  *  <li>comment (flash): The current Comment instance, empty or being added</li>   
  * </ul>
  * </ul>
  *
  * @return void
  */
 public function add()
 {
     if (!isset($this->currentUser)) {
         throw new Exception("Not in session. Adding posts requires login");
     }
     if (isset($_POST["id"])) {
         // reaching via HTTP Post...
         // Get the Post object from the database
         $postid = $_POST["id"];
         $post = $this->postmapper->findById($postid);
         // Does the post exist?
         if ($post == NULL) {
             throw new Exception("no such post with id: " . $postid);
         }
         // Create and populate the Comment object
         $comment = new Comment();
         $comment->setContent($_POST["content"]);
         $comment->setAuthor($this->currentUser);
         $comment->setPost($post);
         try {
             // validate Comment object
             $comment->checkIsValidForCreate();
             // if it fails, ValidationException
             // save the Comment object into the database
             $this->commentmapper->save($comment);
             // POST-REDIRECT-GET
             // Everything OK, we will redirect the user to the list of posts
             // We want to see a message after redirection, so we establish
             // a "flash" message (which is simply a Session variable) to be
             // get in the view after redirection.
             $this->view->setFlash("Comment \"" . $post->getTitle() . "\" successfully added.");
             // perform the redirection. More or less:
             // header("Location: index.php?controller=posts&action=view&id=$postid")
             // die();
             $this->view->redirect("posts", "view", "id=" . $post->getId());
         } catch (ValidationException $ex) {
             $errors = $ex->getErrors();
             // Go back to the form to show errors.
             // However, the form is not in a single page (comments/add)
             // It is in the View Post page.
             // We will save errors as a "flash" variable (third parameter true)
             // and redirect the user to the referring page
             // (the View post page)
             $this->view->setVariable("comment", $comment, true);
             $this->view->setVariable("errors", $errors, true);
             $this->view->redirect("posts", "view", "id=" . $post->getId());
         }
     } else {
         throw new Exception("No such post id");
     }
 }
开发者ID:ragomez,项目名称:abp2015,代码行数:76,代码来源:CommentsController.php

示例5: executeInsertComment

 function executeInsertComment(sfWebRequest $request)
 {
     $name = $request->getParameter('author');
     $content = $request->getParameter('content');
     $article_id = $request->getParameter('article_id');
     $comment = new Comment();
     $comment->setAuthor($name);
     $comment->setContent($content);
     $comment->setArticleId($article_id);
     $comment->save();
     echo 'ok';
     $this->redirect('view/showComments?id=' . $article_id);
     //$this->redirect("view/ShowComments",$comment);
 }
开发者ID:rfeizi,项目名称:sample-codes,代码行数:14,代码来源:actions.class.php

示例6: getAllBySubjectId

 public function getAllBySubjectId($subId)
 {
     $query = "SELECT * FROM comments WHERE subjectId = {$subId}";
     $comments = [];
     foreach ($this->connection->query($query) as $row) {
         $comment = new Comment();
         $comment->setSubjectId($row['subjectId']);
         $comment->setDate($row['date']);
         $comment->setText($row['text']);
         $comment->setAuthor($row['author']);
         $comments[] = $comment;
     }
     return $comments;
 }
开发者ID:einorler,项目名称:DB-namu-darbai,代码行数:14,代码来源:CommentRepository.php

示例7: add

 /**
  * Metodo del controlador Comments cuya funcionalidad es insertar un comentario
  * en un post.
  * Verifica que el usuario ha iniciado sesion y que el post existe
  *
  * @throws Exception Si el usuario no inicio sesion
  * @return void
  */
 public function add()
 {
     if (!isset($this->currentUser)) {
         throw new Exception("Not in session. Adding comments requires login");
     }
     if (isset($_GET["id"])) {
         // reaching via HTTP Post...
         // Se obtiene el post de la BD
         $idPost = $_GET["id"];
         $post = $this->postDAO->findByIdPost($idPost);
         // Si no existe el post lanza una excepcion
         if ($post == NULL) {
             throw new Exception("no such post with id: " . $idPost);
         }
         // Crea el objeto Comment
         $comment = new Comment();
         $comment->setDate(date("Y-m-d H:i:s"));
         $comment->setContent($_POST["content"]);
         $comment->setAuthor($this->currentUser->getEmail());
         $comment->setIdPost($post->getIdPost());
         try {
             // Valida el comentario, si falla lanza una excepcion
             $comment->checkIsValidForCreate();
             // Guarda el comentario en la BD
             $this->commentDAO->save($comment);
             // Redirige al post
             $this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
         } catch (ValidationException $ex) {
             $errors = $ex->getErrors();
             $this->view->setVariable("comment", $comment, true);
             $this->view->setVariable("errors", $errors, true);
             $this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
         }
     } else {
         throw new Exception("No such post id");
     }
 }
开发者ID:adri229,项目名称:TSW_Proyect,代码行数:45,代码来源:CommentsController.php

示例8: dbConnection

<?php

namespace Akademija\ActiveRecord;

include_once 'Theme.php';
include_once 'Comment.php';
include_once 'dbConnection.php';
if (isset($_POST["themeId"])) {
    $db = new dbConnection('localhost', 'root', '', 'akademija-nd');
    $db = $db->connect();
    $themeId = (int) $_POST["themeId"];
    $theme = new Theme($db);
    $theme = $theme->load($themeId);
    $comment = new Comment($db);
    $comment->setThemeId($themeId);
    $comment->setDate(date("Y-m-d H:i:s"));
    $comment->setAuthor($_POST["author"]);
    $comment->setComment($_POST["comment"]);
    $theme->addComments($comment);
    echo "<h2>Komentaras pridetas!</h2>";
} else {
    echo "<h2>Klaida!</h2>";
}
//header( "Refresh:15; url=List.php", true, 303);
echo '<a href="List.php"><- Atgal</a>';
开发者ID:semaska-tomas,项目名称:mysql-nd3,代码行数:25,代码来源:Add.php

示例9: DatabaseWrapper

<?php

require_once 'Comment.php';
require_once '../databaseWrapper.php';
$dbWrapper = new DatabaseWrapper();
$connection = $dbWrapper->getConnection();
$ids = [];
foreach ($connection->query('SELECT id FROM temos') as $row) {
    $ids[] = $row['id'];
}
$text = "Lambada lambada lambada";
$comment = new Comment($connection);
$comment->setAuthor('Anonymous');
$comment->setSubjectID($ids[rand(0, sizeof($ids) - 1)]);
$comment->setText($text);
$comment->save();
header('Location:  Controller.php');
开发者ID:einorler,项目名称:DB-namu-darbai,代码行数:17,代码来源:AddComment.php

示例10: CommentRepository

<?php

namespace sql_nd_3\DDD;

require_once "Comment.php";
require_once "CommentRepository.php";
require_once "TopicRepository.php";
$commentRepository = new CommentRepository();
$topicRepository = new TopicRepository();
$bla = "blablablabla";
$comment = new Comment();
$comment->setAuthor('Author' . rand(0, 1000));
$comment->setTopicID($topicRepository->getRandomId());
$comment->setComment(substr($bla, 0, rand(12, strlen($bla))));
$commentRepository->saveComment($comment);
echo "<div>" . $comment->getTopicID() . "</div>";
echo "<div>" . $comment->getAuthor() . "</div>";
echo "<div>" . $comment->getComment() . "</div>";
开发者ID:ZygimantasKoncius,项目名称:sql_nd_3,代码行数:18,代码来源:CommentAdder.php

示例11: Comment

<?php

require_once '../entity/CommentRep.php';
require_once '../entity/ThemeRep.php';
if (isset($_GET['theme_id']) && is_numeric($_GET['theme_id'])) {
    $comment = new Comment();
    $comment->setDate((new DateTime('now'))->format('Y-m-d H:i:s'));
    $comment->setAuthor(isset($_GET['author']) ? $_GET['author'] : 'bet koks autorius');
    $comment->setComment(isset($_GET['comment']) ? $_GET['comment'] : 'bet koks komentaras');
    $comment->setThemeId($_GET['theme_id']);
    $themeRep = new ThemeRep();
    $theme = $themeRep->findById($_GET['theme_id']);
    if (empty($theme)) {
        echo 'Tema su id ' . $_GET['theme_id'] . ' neegzistuoja';
        return;
    }
    $themeRep->increaseCommentCount($theme);
    $commentRep = new CommentRep();
    $commentRep->save($comment);
    echo 'Komentaras pridetas.';
} else {
    echo 'Reikalingas temos id.';
}
开发者ID:sedvis,项目名称:mysql-nd,代码行数:23,代码来源:add.php

示例12: Article

CommentPeer::doDeleteAll();
ArticlePeer::doDeleteAll();
AuthorPeer::doDeleteAll();

$article1 = new Article();
$article1->setTitle('aaaaa');
$article1->setCategory($category1);
$article1->save();
$author1 = new Author();
$author1->setName('John');
$author1->save();
$comment = new Comment();
$comment->setContent('foo');
$comment->setArticleId($article1->getId());
$comment->setAuthor($author1);
$comment->save();
$article = sfPropelFinder::from('Article')->join('Comment')->join('Author')->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'you can chain several join() statements');
$article = sfPropelFinder::from('Article')->join('Comment')->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'join() can be omitted if column names are explicit');
$article = sfPropelFinder::from('Article')->joinComment()->joinAuthor()->where('Author.Name', 'John')->findOne();
$t->is($article->getTitle(), 'aaaaa', 'joinXXX() does a join according to the XXX column name');

$comment = sfPropelFinder::from('Comment')->join('Article')->join('Author')->where('Author.Name', 'John')->findOne();
$t->is($comment->getContent(), 'foo', 'you can add several join() statements');
$t->is($comment->getArticle()->getTitle(), 'aaaaa', 'you can add several join() statements');
$t->is($comment->getAuthor()->getName(), 'John', 'you can add several join() statements');

/***************************************************************/
/* sfPropelFinder::join($classAndAlias) and subsequend where() */
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:30,代码来源:sfPropelFinderJoinTest.php

示例13: createComment

 public function createComment($postId, $data)
 {
     $currentUser = parent::authenticateUser();
     $post = $this->postMapper->findById($postId);
     if ($post == NULL) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad request');
         echo "Post with id " . $postId . " not found";
     }
     $comment = new Comment();
     $comment->setContent($data->content);
     $comment->setAuthor($currentUser);
     $comment->setPost($post);
     try {
         $comment->checkIsValidForCreate();
         // if it fails, ValidationException
         $this->commentMapper->save($comment);
         header($_SERVER['SERVER_PROTOCOL'] . ' 201 Created');
     } catch (ValidationException $e) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad request');
         echo json_encode($e->getErrors());
     }
 }
开发者ID:xrlopez,项目名称:TSW,代码行数:22,代码来源:PostRest.php

示例14: Comment

<?php

require_once '../model/Comment.php';
require_once '../model/Theme.php';
if (isset($_GET['theme_id']) && is_numeric($_GET['theme_id'])) {
    $comment = new Comment();
    $comment->setDate((new DateTime('now'))->format('Y-m-d H:i:s'));
    $comment->setAuthor(isset($_GET['author']) ? $_GET['author'] : 'nežinomas autorius');
    $comment->setComment(isset($_GET['comment']) ? $_GET['comment'] : 'nežinomas komentaras');
    $comment->setThemeId($_GET['theme_id']);
    $theme = Theme::findById($_GET['theme_id']);
    if (empty($theme)) {
        echo 'Tema ' . $_GET['theme_id'] . ' neegzistuoja';
        return;
    }
    $theme->increaseCommentsCount();
    $comment->save();
    echo 'Komentaras pridetas.';
} else {
    echo 'Reikalingas temos id.';
}
开发者ID:sedvis,项目名称:mysql-nd,代码行数:21,代码来源:add.php


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