本文整理汇总了PHP中CommentModel::where方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::where方法的具体用法?PHP CommentModel::where怎么用?PHP CommentModel::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentModel
的用法示例。
在下文中一共展示了CommentModel::where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embed
/**
* Alternate version of Index that uses the embed master view.
*
* @param int $DiscussionID Unique identifier, if discussion has been created.
* @param string $DiscussionStub Deprecated.
* @param int $Offset
* @param int $Limit
*/
public function embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $Limit = '')
{
$this->title(t('Comments'));
// Add theme data
$this->Theme = c('Garden.CommentsTheme', $this->Theme);
Gdn_Theme::section('Comments');
// Force view options
$this->MasterView = 'empty';
$this->CanEditComments = false;
// Don't show the comment checkboxes on the embed comments page
// Add some css to help with the transparent bg on embedded comments
if ($this->Head) {
$this->Head->addString('<style type="text/css">
body { background: transparent !important; }
</style>');
}
// Javascript files & options
$this->addJsFile('jquery.gardenmorepager.js');
$this->addJsFile('jquery.autosize.min.js');
$this->addJsFile('discussion.js');
$this->removeJsFile('autosave.js');
$this->addDefinition('DoInform', '0');
// Suppress inform messages on embedded page.
$this->addDefinition('SelfUrl', Gdn::request()->PathAndQuery());
$this->addDefinition('Embedded', true);
// Define incoming variables (prefer querystring parameters over method parameters)
$DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
$DiscussionID = getIncomingValue('vanilla_discussion_id', $DiscussionID);
$Offset = getIncomingValue('Offset', $Offset);
$Limit = getIncomingValue('Limit', $Limit);
$vanilla_identifier = getIncomingValue('vanilla_identifier', '');
// Only allow vanilla identifiers of 32 chars or less - md5 if larger
if (strlen($vanilla_identifier) > 32) {
$vanilla_identifier = md5($vanilla_identifier);
}
$vanilla_type = getIncomingValue('vanilla_type', 'page');
$vanilla_url = getIncomingValue('vanilla_url', '');
$vanilla_category_id = getIncomingValue('vanilla_category_id', '');
$ForeignSource = array('vanilla_identifier' => $vanilla_identifier, 'vanilla_type' => $vanilla_type, 'vanilla_url' => $vanilla_url, 'vanilla_category_id' => $vanilla_category_id);
$this->setData('ForeignSource', $ForeignSource);
// Set comment sorting
$SortComments = c('Garden.Embed.SortComments') == 'desc' ? 'desc' : 'asc';
$this->setData('SortComments', $SortComments);
// Retrieve the discussion record
$Discussion = false;
if ($DiscussionID > 0) {
$Discussion = $this->DiscussionModel->getID($DiscussionID);
} elseif ($vanilla_identifier != '' && $vanilla_type != '') {
$Discussion = $this->DiscussionModel->GetForeignID($vanilla_identifier, $vanilla_type);
}
// Set discussion data if we have one for this page
if ($Discussion) {
// Allow Vanilla.Comments.View to be defined to limit access to embedded comments only.
// Otherwise, go with normal discussion view permissions. Either will do.
$this->permission(array('Vanilla.Discussions.View', 'Vanilla.Comments.View'), false, 'Category', $Discussion->PermissionCategoryID);
$this->setData('Discussion', $Discussion, true);
$this->setData('DiscussionID', $Discussion->DiscussionID, true);
$this->title($Discussion->Name);
// Actual number of comments, excluding the discussion itself
$ActualResponses = $Discussion->CountComments;
// Define the query offset & limit
if (!is_numeric($Limit) || $Limit < 0) {
$Limit = c('Garden.Embed.CommentsPerPage', 30);
}
$OffsetProvided = $Offset != '';
list($Offset, $Limit) = offsetLimit($Offset, $Limit);
$this->Offset = $Offset;
if (c('Vanilla.Comments.AutoOffset')) {
if ($ActualResponses <= $Limit) {
$this->Offset = 0;
}
if ($this->Offset == $ActualResponses) {
$this->Offset -= $Limit;
}
} elseif ($this->Offset == '') {
$this->Offset = 0;
}
if ($this->Offset < 0) {
$this->Offset = 0;
}
// Set the canonical url to have the proper page title.
$this->canonicalUrl(discussionUrl($Discussion, pageNumber($this->Offset, $Limit)));
// Load the comments.
$CurrentOrderBy = $this->CommentModel->orderBy();
if (stringBeginsWith(GetValueR('0.0', $CurrentOrderBy), 'c.DateInserted')) {
$this->CommentModel->orderBy('c.DateInserted ' . $SortComments);
// allow custom sort
}
$this->setData('Comments', $this->CommentModel->getByDiscussion($Discussion->DiscussionID, $Limit, $this->Offset), true);
if (count($this->CommentModel->where()) > 0) {
$ActualResponses = false;
}
//.........这里部分代码省略.........
示例2: testGetUserByCommentId
public function testGetUserByCommentId()
{
$commentTable = new CommentModel();
$map['content'] = 'XXX';
$comment = $commentTable->where($map)->find();
$user = $commentTable->getUserByCommentId($comment['id']);
$this->assertTrue($user['phone'] == '444444');
}