<commit_before><?php


namespace Core\Database\Engine;


class MySQLEngine extends \PDO implements Engine
{

    private $config;

    /**
     * MySQLEngine constructor.
     * Please use the Factory to maintain instances of the drivers.
     *
     * @param $config array
     * @throws \PDOException
     */
    public function __construct($config) {
        $this->config = $config;

        parent::__construct("mysql:host=" . $config['host'] . ";dbname=" . $config['database'] . ";charset=utf8", $config['user'], $config['pass']);
        $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    }

    /**
     * Get the name of the driver
     * @return string
     */
    public function getDriverName()
    {
        return "MySQL Driver";
    }

    /**
     * Get configuration for instance
     * @return array
     */
    public function getConfiguration()
    {
        return $this->config;
    }

    /**
     * Get native connection. Could be \PDO
     * @return mixed|\PDO
     */
    public function getConnection()
    {
        return $this;
    }


    /**
     * Select from the database
     *
     * @param  string      $sql       sql query
     * @param  array       $array     named params
     * @param  int         $fetchMode Fetch mode (use \PDO::FETCH_*)
     * @param  string|null $class     class name for using with \PDO::FETCH_CLASS
     * @return array                  returns an array of records
     */
    public function select($sql, $array = array(), $fetchMode = \PDO::FETCH_OBJ, $class = null)
    {
        $stmt = $this->prepare($sql);
        foreach ($array as $key => $value) {
            if (is_int($value)) {
                $stmt->bindValue("$key", $value, \PDO::PARAM_INT);
            } else {
                $stmt->bindValue("$key", $value);
            }
        }

        $stmt->execute();

        $fetched = $stmt->fetchAll($fetchMode, $class);<commit_msg>Undo last a bit, didn't work with pdo, some weird bug I think.<commit_after><?php


namespace Core\Database\Engine;


class MySQLEngine extends \PDO implements Engine
{

    private $config;

    /**
     * MySQLEngine constructor.
     * Please use the Factory to maintain instances of the drivers.
     *
     * @param $config array
     * @throws \PDOException
     */
    public function __construct($config) {
        $this->config = $config;

        parent::__construct("mysql:host=" . $config['host'] . ";dbname=" . $config['database'] . ";charset=utf8", $config['user'], $config['pass']);
        $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    }

    /**
     * Get the name of the driver
     * @return string
     */
    public function getDriverName()
    {
        return "MySQL Driver";
    }

    /**
     * Get configuration for instance
     * @return array
     */
    public function getConfiguration()
    {
        return $this->config;
    }

    /**
     * Get native connection. Could be \PDO
     * @return mixed|\PDO
     */
    public function getConnection()
    {
        return $this;
    }


    /**
     * Select from the database
     *
     * @param  string      $sql       sql query
     * @param  array       $array     named params
     * @param  int         $fetchMode Fetch mode (use \PDO::FETCH_*)
     * @param  string|null $class     class name for using with \PDO::FETCH_CLASS
     * @return array                  returns an array of records
     */
    public function select($sql, $array = array(), $fetchMode = \PDO::FETCH_OBJ, $class = null)
    {
        $stmt = $this->prepare($sql);
        foreach ($array as $key => $value) {
            if (is_int($value)) {
                $stmt->bindValue("$key", $value, \PDO::PARAM_INT);
            } else {
                $stmt->bindValue("$key", $value);
            }
        }

        $stmt->execute();

        $fetched = array();
        if ($fetchMode === \PDO::FETCH_CLASS) {
            $fetched = $stmt->fetchAll($fetchMode, $class);
        } else {
            $fetched = $stmt->fetchAll($fetchMode);
        }

{'fraction_non_alphanumeric': 0.1367542352074638, 'fraction_numerical': 0.0004910385465259023, 'mean_word_length': 1.9479015918958031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '3390174', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1184, 'n_words': 309}