<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace acd;

/**
 * Description of database
 *
 * @author Acidvertigo
 */
class Database 
{

    /** @var object|null Database instance */
    private static $conn = null;
    
    /** @var array $db: database configuration array */
    private $db = array();

    private function __construct() {}
    
    private function __clone() {}
    
    private function __wakeup() {}

    /**
     * Connects to the database
     * @param \acd\Registry $registry
     * @return null|object
     */
    public static function connect(Registry $registry)
    {
        // One connection through whole application
        if (null == self::$conn) {
            try {
                // Load the database connection parameters from the Registry
                $db = $registry->get('config')['database'];

                // Starts connection
                self::$conn = new \PDO("mysql:host=".$db['HOST'].";dbname=".$db['NAME'], $db['USERNAME'], $db['PASSWORD']);
            } catch (\PDOException $e) {
                echo $e->getMessage();
            }
        }
        return self::$conn;
    }

    /**
     * Close database connection
     */
    public static function disconnect()
    {
        self::$conn = null;
    }

}<commit_msg>Add PDO options<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace acd;

/**
 * Description of database
 *
 * @author Acidvertigo
 */
class Database 
{

    /** @var object|null Database instance */
    private static $conn = null;
    
    /** @var array $db: database configuration array */
    private $db = array();

    private function __construct() {}
    
    private function __clone() {}
    
    private function __wakeup() {}

    /**
     * Connects to the database
     * @param \acd\Registry $registry
     * @return null|object
     */
    public static function connect(Registry $registry)
    {
        // One connection through whole application
        if (null == self::$conn) {
            try {
                // Load the database connection parameters from the Registry
                $db = $registry->get('config')['database'];
                $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);

                // Starts connection
                self::$conn = new \PDO("mysql:host=".$db['HOST'].";dbname=".$db['NAME'], $db['USERNAME'], $db['PASSWORD'], $options);
            } catch (\PDOException $e) {
                echo $e->getMessage();
            }
        }
        return self::$conn;
    }

    /**
     * Close database connection
     */
    public static function disconnect()
    {
        self::$conn = null;
    }

}
{'fraction_non_alphanumeric': 0.12907474481396114, 'fraction_numerical': 0.0, 'mean_word_length': 2.125514403292181, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '718557', 'n_tokens_mistral': 824, 'n_tokens_neox': 806, 'n_words': 244}