Ejemplo n.º 1
0
 /**
  * 针对数据查询
  * 要求返回数据确保评论字段的存在,以便排序
  * @return array
  */
 private function query()
 {
     //echo "QUERY:" . c()->getTimer()->get_second() . "<br>";
     if (!isset($this->count_info['max'])) {
         $this->throwMsg(-7);
     }
     $tops = $this->db->select("comments", ['[><]' . $this->relation_table => ['id' => 'comments_id']], ['comments.id' => 'id'], ['AND' => [$this->relation_table . "." . $this->relation_field => $this->id, 'comments.comment_parent_top' => NULL], 'LIMIT' => [$this->count_info['number'] * ($this->count_info['now'] - 1), $this->count_info['number']]]);
     $ids = [];
     foreach ($tops as $v) {
         $ids[] = +$v['id'];
     }
     $list = $this->db->select("comments", ['[><]users' => ['users_id' => 'id'], '[>]users_like_comments' => ['id' => 'comments_id', '______' => ['users_like_comments.users_id' => is_login() ? login_user()->getId() : 0]]], ['users.id' => 'user_id', 'users.user_name' => 'user_name', 'users.user_aliases' => 'user_aliases', 'users.user_email' => 'user_email', 'users.user_url' => 'user_url', 'users.user_status' => 'user_status', 'users.user_registered_time' => 'user_registered_time', 'users.user_last_login_time' => 'user_last_login_time', 'users.user_avatar' => 'user_avatar', 'comments.id' => 'comment_id', 'comments.comment_content' => 'comment_content', 'comments.comment_time' => 'comment_time', 'comments.comment_parent' => 'comment_parent', 'comments.comment_status' => 'comment_status', 'comments.comment_top' => 'comment_top', 'comments.comment_like_count' => 'comment_like_count', 'comments.comment_agent' => 'comment_agent', 'comments.comment_ip' => 'comment_ip', 'users_like_comments.like_time' => 'comment_like_time'], ['OR' => ['comments.id' => $ids, 'comments.comment_parent_top' => $ids], 'ORDER' => 'comments.id ' . (comment_order_desc() ? "DESC" : "ASC")]);
     if ($list === false) {
         $this->throwMsg(-8);
         Log::write(implode(",", $this->db->error()['read']), Log::SQL);
     }
     //		print_r($this->db->last_query());
     //		var_dump($list);
     //		echo "QUERY END:" . c()->getTimer()->get_second() . "<br>";
     return $list;
 }
Ejemplo n.º 2
0
						<input name="allowed_comment" value="yes" type="checkbox"<?php 
echo allowed_comment() ? " checked" : "";
?>
> 是否允许用户评论
					</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">评论排序</label>

			<div class="col-sm-10">
				<div class="checkbox">
					<label>
						<input name="comment_order_desc" value="yes" type="checkbox"<?php 
echo comment_order_desc() ? " checked" : "";
?>
> 使用倒序排列评论
					</label>
				</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label">邮件提醒</label>

			<div class="col-sm-10">
				<div class="checkbox">
					<label>
						<input name="email_notice" value="yes" type="checkbox"<?php 
echo email_notice() ? " checked" : "";