<commit_before><?php

class Comment extends Alkaline{
	public $comments;
	public $comment_ids;
	public $comment_count;
	public $comment_count_result;
	public $page;
	public $page_begin;
	public $page_count;
	public $page_first;
	public $page_limit;
	public $page_next;
	public $page_previous;
	public $photo_ids;
	protected $sql;
	protected $sql_conds;
	protected $sql_limit;
	protected $sql_sorts;
	protected $sql_from;
	protected $sql_tables;
	protected $sql_group_by;
	protected $sql_having;
	protected $sql_having_fields;
	protected $sql_params;
	protected $sql_order_by;
	protected $sql_where;
	
	public function __construct($comment_ids=null){
		parent::__construct();
		
		// Store data to object
		$this->comments = array();
		$this->comment_ids = array();
		$this->page = 1;
		$this->page_limit = LIMIT;
		$this->photo_ids = array();
		$this->sql = 'SELECT *';
		$this->sql_conds = array();
		$this->sql_limit = '';
		$this->sql_sorts = array();
		$this->sql_from = '';
		$this->sql_tables = array('comments');
		$this->sql_join = '';
		$this->sql_join_type = '';
		$this->sql_join_tables = array();
		$this->sql_join_on = array();
		$this->sql_group_by = ' GROUP BY comments.comment_id';
		$this->sql_having = '';
		$this->sql_injection = '';
		$this->sql_having_fields = array();
		$this->sql_params = array();
		$this->sql_order_by = '';
		$this->sql_where = '';
		
		if(!empty($comment_ids)){
			$comment_ids = parent::convertToIntegerArray($comment_ids);
			$this->sql_conds[] = 'comments.comment_id IN (' . implode(', ', $comment_ids) . ')';
		}
	}
	
	public function __destruct(){
		parent::__destruct();
	}
	
	// FIND BY SEARCH
	public function search($search=null){
		// Error checking
		if(empty($search)){ return false; }
		
		// Prepare input
		$search_lower = strtolower($search);
		$search_lower = preg_replace('#\s#', '%', $search_lower);
		$search_lower = '%' . $search_lower . '%';
		
		$query = $this->prepare('SELECT comments.comment_id FROM comments WHERE (LOWER(comment_text) LIKE :comment_text) OR (LOWER(comment_author_name) LIKE :comment_author_name) OR (LOWER(comment_author_url) LIKE :comment_author_url) OR (LOWER(comment_author_email) LIKE :comment_author_email) OR (LOWER(comment_author_ip) LIKE :comment_author_ip);');
		$query->execute(array(':comment_text' => $search_lower, ':comment_author_name' => $search_lower, ':comment_author_url' => $search_lower, ':comment_author_email' => $search_lower, ':comment_author_ip' => $search_lower));
		$comments = $query->fetchAll();
		
		$comment_ids = array();
		
		foreach($comments as $comment){
			$comment_ids[] = $comment['comment_id'];
		}
		
		if(count($comment_ids)){
			$this->sql_conds[] = 'comments.comment_id IN (' . implode(', ', $comment_ids) . ')';
		}
		else{
			$this->sql_conds[] = 'comments.comment_id IN (NULL)';
		}
		
		return true;
	}
	
	// FIND BY STATUS
	public function status($status=null){
		// Error checking
		if(empty($status)){ return false; }
		
		// Convert strings
		if(is_string($status)){
			$levels = array('spam' => -1, 'unpublished' => 0, 'published' => 1);
			if(array_key_exists($status, $levels)){
				$status = $levels[$status];
			}
			else{
				return false;
			}
			
			// Set fields to search
			$this->sql_conds[] = 'comments.comment_status = ' . $status;
		}
		elseif(is_integer($privacy)){
			$this->sql_conds[] = 'comments.comment_status = ' . $status;
			
		}
		elseif(is_array($privacy)){
			parent::convertToIntegerArray($privacy);
			
			// Set fields to search
			$this->sql_conds[] = 'comments.comment_status IN (' . implode(', ', $status) . ')';
		}
		else{
			return false;
		}
		
		return true;
	}

	// FIND BY DATE UPLOADED
	public function created($begin=null, $end=null){
		// Error checking
		if(empty($begin) and empty($end)){ return false; }
		
		// Set begin date
		if(!empty($begin)){
			if(is_int($begin)){ $begin = strval($begin); }
			if(strlen($begin) == 4){ $begin .= '-01-01'; }
			$begin = date('Y-m-d', strtotime($begin));
			$this->sql_conds[] = 'comments.comment_created >= :comment_created_begin';
			$this->sql_params[':comment_created_begin'] = $begin . ' 00:00:00';<commit_msg>Fixed ::Comment bugs<commit_after><?php

class Comment extends Alkaline{
	public $comments;
	public $comment_ids;
	public $comment_count;
	public $comment_count_result;
	public $page;
	public $page_begin;
	public $page_count;
	public $page_first;
	public $page_limit;
	public $page_next;
	public $page_previous;
	public $photo_ids;
	protected $sql;
	protected $sql_conds;
	protected $sql_limit;
	protected $sql_sorts;
	protected $sql_from;
	protected $sql_tables;
	protected $sql_group_by;
	protected $sql_having;
	protected $sql_having_fields;
	protected $sql_params;
	protected $sql_order_by;
	protected $sql_where;
	
	public function __construct($comment_ids=null){
		parent::__construct();
		
		// Store data to object
		$this->comments = array();
		$this->comment_ids = array();
		$this->page = 1;
		$this->page_limit = LIMIT;
		$this->photo_ids = array();
		$this->sql = 'SELECT *';
		$this->sql_conds = array();
		$this->sql_limit = '';
		$this->sql_sorts = array();
		$this->sql_from = '';
		$this->sql_tables = array('comments');
		$this->sql_join = '';
		$this->sql_join_type = '';
		$this->sql_join_tables = array();
		$this->sql_join_on = array();
		$this->sql_group_by = ' GROUP BY comments.comment_id';
		$this->sql_having = '';
		$this->sql_injection = '';
		$this->sql_having_fields = array();
		$this->sql_params = array();
		$this->sql_order_by = '';
		$this->sql_where = '';
		
		if(!empty($comment_ids)){
			$comment_ids = parent::convertToIntegerArray($comment_ids);
			$this->sql_conds[] = 'comments.comment_id IN (' . implode(', ', $comment_ids) . ')';
		}
	}
	
	public function __destruct(){
		parent::__destruct();
	}
	
	// FIND BY SEARCH
	public function search($search=null){
		// Error checking
		if(empty($search)){ return false; }
		
		// Prepare input
		$search_lower = strtolower($search);
		$search_lower = preg_replace('#\s#', '%', $search_lower);
		$search_lower = '%' . $search_lower . '%';
		
		$query = $this->prepare('SELECT comments.comment_id FROM comments WHERE (LOWER(comment_text) LIKE :comment_text) OR (LOWER(comment_author_name) LIKE :comment_author_name) OR (LOWER(comment_author_url) LIKE :comment_author_url) OR (LOWER(comment_author_email) LIKE :comment_author_email) OR (LOWER(comment_author_ip) LIKE :comment_author_ip);');
		$query->execute(array(':comment_text' => $search_lower, ':comment_author_name' => $search_lower, ':comment_author_url' => $search_lower, ':comment_author_email' => $search_lower, ':comment_author_ip' => $search_lower));
		$comments = $query->fetchAll();
		
		$comment_ids = array();
		
		foreach($comments as $comment){
			$comment_ids[] = $comment['comment_id'];
		}
		
		if(count($comment_ids)){
			$this->sql_conds[] = 'comments.comment_id IN (' . implode(', ', $comment_ids) . ')';
		}
		else{
			$this->sql_conds[] = 'comments.comment_id IN (NULL)';
		}
		
		return true;
	}
	
	// FIND BY STATUS
	public function status($status=null){
		// Error checking
		if(empty($status)){ return false; }
		
		// Convert strings
		if(is_string($status)){
			$levels = array('spam' => -1, 'unpublished' => 0, 'published' => 1);
			if(array_key_exists($status, $levels)){
				$status = $levels[$status];
			}
			else{
				return false;
			}
			
			// Set fields to search
			$this->sql_conds[] = 'comments.comment_status = ' . $status;
		}
		elseif(is_integer($status)){
			$this->sql_conds[] = 'comments.comment_status = ' . $status;
			
		}
		elseif(is_array($status)){
			parent::convertToIntegerArray($privacy);
			
			// Set fields to search
			$this->sql_conds[] = 'comments.comment_status IN (' . implode(', ', $status) . ')';
		}
		else{
			return false;
		}
		
		return true;
	}

	// FIND BY DATE UPLOADED
	public function created($begin=null, $end=null){
		// Error checking
		if(empty($begin) and empty($end)){ return false; }
		
		// Set begin date
		if(!empty($begin)){
			if(is_int($begin)){ $begin = strval($begin); }
			if(strlen($begin) == 4){ $begin .= '-01-01'; }
			$begin = date('Y-m-d', strtotime($begin));
			$this->sql_conds[] = 'comments.comment_created >= :comment_created_begin';
			$this->sql_params[':comment_created_begin'] = $begin . ' 00:00:00';
{'fraction_non_alphanumeric': 0.17468934732778382, 'fraction_numerical': 0.003619254433586681, 'mean_word_length': 4.386614684860299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '69150', 'n_tokens_mistral': 3246, 'n_tokens_neox': 2871, 'n_words': 557}