本文整理汇总了PHP中Comments::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::query方法的具体用法?PHP Comments::query怎么用?PHP Comments::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::query方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comments
/**
* 获取该模型的所有评论
* 这个其实也可以变成一个通用的方法落实在myModel中的
* @return null|\Phalcon\Mvc\Model\ResultsetInterface
*/
public function comments()
{
/** @var myModel $this */
return $this->make('comments', function () {
return Comments::query()->leftJoin('Users', 'Users.id = Comments.user_id')->where('Comments.commentable_id = :id:')->andWhere('Comments.commentable_type = :type:')->bind(['id' => $this->id, 'type' => get_class($this)])->orderBy('Comments.updated_at Desc')->columns(['Comments.*', 'Users.*'])->execute();
});
}
示例2: comments
public function comments()
{
if (null == $this->comments) {
$this->comments = Comments::query()->where('user_id = :user:', ['user' => $this->id])->orderBy('created_at DESC')->execute();
}
return $this->comments;
}
示例3: comments
public function comments()
{
if ($this->comments == null) {
$this->comments = Comments::query()->where('commentable_id = :tag_id:')->andWhere('commentable_type = :type:')->bind(['tag_id' => $this->id, 'type' => get_class($this)])->orderBy('updated_at Desc')->execute();
}
return $this->comments;
}
示例4: indexAction
/**
* Index action
*/
public function indexAction()
{
$numberPage = $this->request->getQuery("page", "int", 1);
$comments = Comments::query()->order("submitted DESC")->execute();
$paginator = new Paginator(array("data" => $comments, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
示例5: getEpisodesComments
public function getEpisodesComments()
{
if ([] == $this->EpisodesComments) {
$episodes = $this->getEpisodes();
$ids = [];
foreach ($episodes as $episode) {
$ids[] = $episode->id;
}
if (count($ids)) {
$this->EpisodesComments = Comments::query()->leftJoin('Episodes', 'Episodes.id = Comments.commentable_id')->where('Comments.commentable_type = :type:', ['type' => 'Episodes'])->inWhere('Comments.commentable_id', $ids)->columns(['Comments.*', 'Episodes.*'])->orderBy('Comments.updated_at DESC')->execute();
}
}
return $this->EpisodesComments;
}
示例6: httpResponse
$arr = $torrent->getFiles($params[1]);
httpResponse($arr);
break;
case validateRoute('GET', 'torrents/\\d+/peers'):
$torrent = new Torrent($db, $user);
list($seeders, $leechers) = $torrent->getPeers((int) $params[1]);
httpResponse(array("seeders" => $seeders, "leechers" => $leechers));
break;
case validateRoute('GET', 'torrents/\\d+/snatchlog'):
$torrent = new Torrent($db, $user);
httpResponse($torrent->getSnatchLog((int) $params[1]));
break;
case validateRoute('GET', 'torrents/\\d+/comments'):
$torrent = new Torrent($db, $user);
$comments = new Comments($db, $user, $torrent);
list($result, $totalCount) = $comments->query((int) $params[1], (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
httpResponse($result, $totalCount);
break;
case validateRoute('POST', 'torrents/\\d+/comments'):
$torrent = new Torrent($db);
$comments = new Comments($db, $user, $torrent);
$comments->add((int) $params[1], $postdata["data"]);
httpResponse($result, $totalCount);
break;
case validateRoute('PATCH', 'torrents/\\d+/comments/\\d+'):
$comments = new Comments($db, $user);
$comments->update((int) $params[1], (int) $params[3], $postdata["postData"]);
httpResponse($result, $totalCount);
break;
case validateRoute('DELETE', 'torrents/\\d+/comments/\\d+'):
$torrent = new Torrent($db, $user);
示例7: getTaggedFileComments
public function getTaggedFileComments()
{
/** @var myModel $this */
return $this->make('taggedFileComments', function () {
$user = \Phalcon\Di::getDefault()->get('auth');
$comments = Comments::query()->leftJoin('Taggables', 'Comments.commentable_type = "Taggables" AND Comments.commentable_id = t1.id', 't1')->where('t1.tag_id = :tag:', ['tag' => $this->id])->leftJoin('Taggables', 't1.taggable_type = t2.taggable_type AND t1.taggable_id = t2.taggable_id', 't2')->andWhere('t2.user_id = :user:', ['user' => $user->id])->groupBy('Comments.id')->orderBy('Comments.updated_at DESC')->leftJoin('Files', 't1.taggable_type = "Files" AND t1.taggable_id = Files.id')->leftJoin('Users', 'Users.id = Comments.user_id')->columns(['Files.*', 'Comments.*', 'Users.*'])->execute();
return $comments;
});
}
示例8: getComments
/**
* @param string $source
* @return array
*/
function getComments($source = 'VuFind')
{
require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
$sql = "SELECT comments.*, CONCAT(LEFT(user.firstname,1), '. ', user.lastname) as fullname, user.displayName as displayName " . "FROM comments RIGHT OUTER JOIN user on comments.user_id = user.id " . "WHERE comments.resource_id = '{$this->id}' ORDER BY comments.created";
//Get a reference to the scope we are in so we can determine how to process the comments.
global $library;
global $user;
//Load all bad words.
require_once ROOT_DIR . '/Drivers/marmot_inc/BadWord.php';
$badWords = new BadWord();
$badWordsList = $badWords->getBadWordExpressions();
$commentList = array();
$commentList['user'] = array();
$commentList['staff'] = array();
$comment = new Comments();
$comment->query($sql);
if ($comment->N) {
while ($comment->fetch()) {
$okToAdd = true;
if (isset($user) && $user != false && $user->id == $comment->user_id) {
//It's always ok to show the user what they wrote
} else {
//Determine if we should censor bad words or hide the comment completely.
$censorWords = true;
if (isset($library)) {
$censorWords = $library->hideCommentsWithBadWords == 0 ? true : false;
}
if ($censorWords) {
$commentText = $comment->comment;
foreach ($badWordsList as $badWord) {
$commentText = preg_replace($badWord, '***', $commentText);
}
$comment->comment = $commentText;
} else {
//Remove comments with bad words
$commentText = trim($comment->comment);
foreach ($badWordsList as $badWord) {
if (preg_match($badWord, $commentText)) {
$okToAdd = false;
break;
}
}
}
}
if ($okToAdd) {
//Remove any hashtags that were added to the review.
if (preg_match('/#.*/', $comment->comment)) {
$comment->comment = preg_replace('/#.*/', '', $comment->comment);
$commentList['staff'][] = clone $comment;
} else {
$commentList['user'][] = clone $comment;
}
}
}
}
return $commentList;
}
示例9: array
$r[$key] = mysqli_real_escape_string($con, $value);
}
$rarr = array('status' => 0);
if ($r['action'] == 'get') {
// get a single post
// with all the fucking comments
$obj = new Posts($r);
$obj->checkInputHas(['postid']);
$obj->addSelection("postid = {$r['postid']}");
$result = $obj->query(ERR_NOPOST, true);
$postarr = mysqli_fetch_assoc($result);
$postarr['vote'] = $obj->getUserVote($r['id'], $r['postid']);
// get comments
$commentObj = new Comments($r);
$commentObj->addSelection("postid=" . $r['postid']);
$result = $commentObj->query();
$postarr['comments'] = array();
while ($row = mysqli_fetch_assoc($result)) {
unset($row['postid']);
$postarr['comments'][] = $row;
}
$rarr = array_merge($postarr, $rarr);
die(json_encode($rarr));
} else {
if ($r['action'] == 'set') {
// create a new post
// send token, userid, content, [groupid, pollid]
$postObj = new Posts($r);
$postObj->checkTokenValid();
$postObj->checkInputHas(['content']);
$postObj->addInsertsFromArray($r, ['id', 'content']);
示例10: deletePage
public function deletePage($minititolo)
{
return parent::query("DELETE FROM {$this->prefix}pagine WHERE minititolo='{$minititolo}'") ? true : false;
}
示例11: getTaggableComments
public function getTaggableComments(Tags $tag = null)
{
/** @var myModel $this */
return $this->make('taggableComments', function () use($tag) {
$query = Comments::query()->leftJoin('Users', 'Comments.user_id = Users.id')->leftJoin('Taggables', 'commentable_type = "Taggables" AND commentable_id = Taggables.id')->leftJoin('Files', 'Taggables.taggable_type = "Files" AND Taggables.taggable_id = Files.id')->leftJoin('Tags', 'Taggables.tag_id = Tags.id')->where('Files.id = :id:', ['id' => $this->id])->orderBy('Comments.updated_at DESC')->columns(['Tags.*', 'Comments.*', 'Users.*']);
if ($tag != null) {
$query = $query->andWhere('Tags.id = :tag:', ['tag' => $tag->id]);
}
return $query->execute();
});
}
示例12: showCommentListAction
public function showCommentListAction()
{
$comments = Comments::query()->orderBy('updated_at Desc')->execute();
foreach ($comments as $c) {
echo $c->created_at . ' - ' . $c->content . '<br>';
}
die;
}