<commit_before><?php namespace helpers;
use \PDO;
/*
 * database Helper - extending PDO to use custom methods
 *
 * @author <NAME> - <EMAIL> - http://www.daveismyname.com
 * @version 2.1
 * @date June 27, 2014
 */
class Database extends PDO{
	
	/**
	 * @var array Array of saved databases for reusing
	 */
	protected static $instances = array();
	
	/**
	 * create database connection based 
	 * 
	 * @param array $group - Array with infomration about connection: DB type, host, DB name, user and password
	 * @author volter9 - <EMAIL>
	 * @author <NAME> - <EMAIL> - http://www.daveismyname.com
	 */
	function __construct ($group = FALSE) {
		// Determining if exists or it's not empty, then use default group defined in config
		$group = !$group || empty($group) ? array (
			'type' => DB_TYPE,
			'host' => DB_HOST,
			'name' => DB_NAME,
			'user' => DB_USER,
			'pass' => <PASSWORD>
		) : $group;
		
		// Group information
		$type = $group['type'];
		$host = $group['host'];
		$name = $group['name'];
		$user = $group['user'];
		$pass = $group['pass'];
		
		// ID for database based on the group information
		$id = "$type.$host.$name.$user.$pass";
		
		// Checking if the same 
		if(!isset(self::$instances[$id])) {
		    	array_push(self::$instances, $id);
		} else {
			return $self::$instances[$id];
		}
		
		try {
			parent::__construct("$type:host=$host;dbname=$name", $user, $pass);
			$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			$this->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
			
			// Setting Database into $instances to avoid duplication
			self::$instances[$id] = $this;
		} catch(PDOException $e){
			//in the event of an error record the error to errorlog.html
			Logger::newMessage($e);
			logger::customErrorMsg();
		}

	}

	/**
	 * method for selecting records from a database
	 * @param  string $sql       sql query
	 * @param  array  $array     named params<commit_msg>Update database.php<commit_after><?php namespace helpers;
use \PDO;
/*
 * database Helper - extending PDO to use custom methods
 *
 * @author <NAME> - <EMAIL> - http://www.daveismyname.com
 * @version 2.1
 * @date June 27, 2014
 */
class Database extends PDO{
	
	/**
	 * @var array Array of saved databases for reusing
	 */
	protected static $instances = array();
	
	/**
	 * create database connection based 
	 * 
	 * @param array $group - Array with infomration about connection: DB type, host, DB name, user and password
	 * @author volter9 - <EMAIL>
	 * @author <NAME> - <EMAIL> - http://www.daveismyname.com
	 */
	function __construct ($group = FALSE) {
		// Determining if exists or it's not empty, then use default group defined in config
		$group = !$group || empty($group) ? array (
			'type' => DB_TYPE,
			'host' => DB_HOST,
			'name' => DB_NAME,
			'user' => DB_USER,
			'pass' => DB_PASS
		) : $group;
		
		// Group information
		$type = $group['type'];
		$host = $group['host'];
		$name = $group['name'];
		$user = $group['user'];
		$pass = $group['pass'];
		
		// ID for database based on the group information
		$id = "$type.$host.$name.$user.$pass";
		
		// Checking if the same 
		if(isset(self::$instances[$id])) {
		    	return self::$instances[$id];
		}
		
		try {
			parent::__construct("$type:host=$host;dbname=$name", $user, $pass);
			$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			$this->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
			
			// Setting Database into $instances to avoid duplication
			self::$instances[$id] = $this;
		} catch(PDOException $e){
			//in the event of an error record the error to errorlog.html
			Logger::newMessage($e);
			logger::customErrorMsg();
		}

	}

	/**
	 * method for selecting records from a database
	 * @param  string $sql       sql query
	 * @param  array  $array     named params
{'fraction_non_alphanumeric': 0.1571652719665272, 'fraction_numerical': 0.005230125523012552, 'mean_word_length': 3.3515358361774745, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6477044', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1243, 'n_words': 361}