<commit_before><?php
/**
 * Habari database specific connection class
 *
 * @package Habari
 */

class MySQLConnection extends DatabaseConnection
{
	/**
	 * Extends default connection method. It will be useful in order to
	 * allow accents and other DB-centric global commands.
	 *
	 * @param string $connect_string a PDO connection string
	 * @param string $db_user the database user name
	 * @param string $db_pass the <PASSWORD>
	 * @return boolean TRUE on success, FALSE on error
	 */
	public function connect ( $connect_string, $db_user, $db_pass )
	{
		// If something went wrong, we don't need to exec the specific commands.
		if( !parent::connect( $connect_string, $db_user, $db_pass ) ) {
			return false;
		}
		$this->pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, true );

		// Everything is OK. Let's update the charset!
		if(!defined('MYSQL_CHAR_SET')) {
			define('MYSQL_CHAR_SET', 'UTF8');
		}
		$this->exec('SET CHARACTER SET ' . MYSQL_CHAR_SET);
		
		return true;
	}

	/**
	 * Database specific SQL translation function, loosely modelled on the<commit_msg>We are transmitting UTF8 data to and from the database. Using SET CHARACTER SET, this breaks with databases using a DB collation that is not utf8. This change makes sure we also set the charset for the connection.<commit_after><?php
/**
 * Habari database specific connection class
 *
 * @package Habari
 */

class MySQLConnection extends DatabaseConnection
{
	/**
	 * Extends default connection method. It will be useful in order to
	 * allow accents and other DB-centric global commands.
	 *
	 * @param string $connect_string a PDO connection string
	 * @param string $db_user the database user name
	 * @param string $db_pass the <PASSWORD>
	 * @return boolean TRUE on success, FALSE on error
	 */
	public function connect ( $connect_string, $db_user, $db_pass )
	{
		// If something went wrong, we don't need to exec the specific commands.
		if( !parent::connect( $connect_string, $db_user, $db_pass ) ) {
			return false;
		}
		$this->pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, true );

		// Everything is OK. Let's update the charset!
		if(!defined('MYSQL_CHAR_SET')) {
			define('MYSQL_CHAR_SET', 'UTF8');
		}
		$this->exec('SET NAMES ' . MYSQL_CHAR_SET);
		
		return true;
	}

	/**
	 * Database specific SQL translation function, loosely modelled on the
{'fraction_non_alphanumeric': 0.10179640718562874, 'fraction_numerical': 0.001710863986313088, 'mean_word_length': 3.955508474576271, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '661108', 'n_tokens_mistral': 757, 'n_tokens_neox': 687, 'n_words': 255}