<commit_before><?php

class Mysql_driver extends Database{

	public function __construct(){
		parent::__construct();
		$this->conn = new mysqli(HOSTNAME, DB_USER, DB_PASSWORD, DATABASE);
		if($this->conn->connect_errno)
			die("Failed to connect to Database: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error);
	}

	public function __destruct(){
		if(isset($this->conn)){
			$this->conn->close();
		}
	}

	public function query($query, $response = TRUE){
		$q = $this->conn->query($query);
		if(!$q){
			throw new APIexception("Query failed: " . $this->conn->error . " Query: ". $query, $this->conn->errno, 400);
		} else {
			if($response){
				if(is_object($q)){
					$arr = array();
					while($res = $q->fetch_assoc()){
						$arr[] = $res;
					}
					if(empty($arr))
						throw new APIexception("No data to display", 12);
						
					return $arr;
				} elseif($this->conn->insert_id){
					preg_match("/^INSERT INTO `(\w+)`/", $query, $table);
					$q = $this->conn->query("SELECT * FROM $table[1] WHERE `id`=".$this->conn->insert_id);
					if(is_object($q)){
						return $q->fetch_assoc();
					}
				} else {
					if($this->conn->affected_rows > 0){
						
					}
					return array('Successful query. '.$this->conn->affected_rows);
				}
					
			}
		}
	}

	public function construct_query($q, $table, $params){
		$table = DB_PREFIX.$table;
		$query = strtoupper($this->guess_action($q, $this->glossary));
		switch($query){
			case 'SELECT':
				if(isset($params['show'])){
					$cols = array();
					foreach($params['show'] as $col){
						$cols[] = "`".$col."`";<commit_msg>Finished queries for updated and deleted queries.<commit_after><?php

class Mysql_driver extends Database{

	public function __construct(){
		parent::__construct();
		$this->conn = new mysqli(HOSTNAME, DB_USER, DB_PASSWORD, DATABASE);
		if($this->conn->connect_errno)
			die("Failed to connect to Database: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error);
	}

	public function __destruct(){
		if(isset($this->conn)){
			$this->conn->close();
		}
	}

	public function query($query, $response = TRUE){
		$q = $this->conn->query($query);
		if(!$q){
			throw new APIexception("Query failed: " . $this->conn->error . " Query: ". $query, $this->conn->errno, 400);
		} else {
			if($response){
				if(is_object($q)){
					$arr = array();
					while($res = $q->fetch_assoc()){
						$arr[] = $res;
					}
					if(empty($arr))
						throw new APIexception("No data to display", 12);
						
					return $arr;
				} elseif($this->conn->insert_id){
					preg_match("/^INSERT INTO `(\w+)`/", $query, $table);
					$q = $this->conn->query("SELECT * FROM $table[1] WHERE `id`=".$this->conn->insert_id);
					if(is_object($q)){
						return $q->fetch_assoc();
					}
				} else {
					if($this->conn->affected_rows > 0){
						preg_match("/`(\w+)`/", $query, $table);
						$resq = $this->conn->query("SELECT * FROM ".$table[0]." ORDER BY `updated` DESC LIMIT ".$this->conn->affected_rows);
						if(is_object($resq)){
							return $resq->fetch_assoc();
						}
					} else {
						return 'No affected rows.';
					}
				}
					
			}
		}
	}

	public function construct_query($q, $table, $params){
		$table = DB_PREFIX.$table;
		$query = strtoupper($this->guess_action($q, $this->glossary));
		switch($query){
			case 'SELECT':
				if(isset($params['show'])){
					$cols = array();
					foreach($params['show'] as $col){
						$cols[] = "`".$col."`";
{'fraction_non_alphanumeric': 0.20882950914899798, 'fraction_numerical': 0.004356665698518733, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, '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': '5510576', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1192, 'n_words': 236}