<commit_before><?php

/**
 * @package KantPHP
 * 
 * @copyright (c) 2011 - 2015 KantPHP Studio, All rights reserved.
 * @license BSD License.
 */
!defined('IN_KANT') && exit('Access Denied');

class MysqlDb extends DbQueryAbstract implements DbQueryInterface {

    /**
     *
     * Open database connection
     *
     * @param config
     */
    public function open($config) {
        $this->config = $config;
        if ($config['autoconnect'] == 1) {
            $this->_connect();
        }
    }

    /**
     *
     * Truly open database connection
     *
     * @return resource a MySQL link identifier on success, or false on
     * failure.
     */
    private function _connect() {
        $func = $this->config['persistent'] == 1 ? 'mysql_pconnect' : 'mysql_connect';
        if (!$this->dbh = @$func($this->config['hostname'] . ":" . $this->config['port'], $this->config['username'], $this->config['password'], 1)) {
            throw new KantException(sprintf('Can not connect to MySQL server or cannot use database.%s', mysql_error()));
        }
        if ($this->version() > '4.1') {
            $charset = isset($this->config['charset']) ? $this->config['charset'] : '';
            $serverset = $charset ? "character_set_connection='$charset',character_set_results='$charset',character_set_client=binary" : '';
            $serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',') . " sql_mode='' ") : '';
            $serverset && mysql_query("SET $serverset", $this->dbh);
        }

        if ($this->config['database'] && !@mysql_select_db($this->config['database'], $this->dbh)) {
            throw new KantException(sprintf('Can not use MySQL server or cannot use database.%s', mysql_error()));
        }
        $this->database = $this->config['database'];
    }

    /**
     *
     * Get MySQL server info
     *
     * @return string the MySQL server version on success&return.falseforfailure;.
     */
    public function version() {
        if (!is_resource($this->dbh)) {
            $this->_connect();
        }
        return mysql_get_server_info($this->dbh);
    }

    /**
     * Free result memory
     */
    public function free() {
        mysql_free_result($this->queryID);
        $this->queryID = null;<commit_msg>MySQL/MysqlDb.php bug fix<commit_after><?php

/**
 * @package KantPHP
 * 
 * @copyright (c) 2011 - 2015 KantPHP Studio, All rights reserved.
 * @license BSD License.
 */
!defined('IN_KANT') && exit('Access Denied');

class MysqlDb extends DbQueryAbstract implements DbQueryInterface {

    /**
     *
     * Open database connection
     *
     * @param config
     */
    public function open($config) {
        $this->config = $config;
        if ($config['autoconnect'] == 1) {
            $this->_connect();
        }
    }

    /**
     *
     * Truly open database connection
     *
     * @return resource a MySQL link identifier on success, or false on
     * failure.
     */
    private function _connect() {
        $func = $this->config['persistent'] == 1 ? 'mysql_pconnect' : 'mysql_connect';
        if (!$this->dbh = @$func($this->config['hostname'] . ":" . $this->config['port'], $this->config['username'], $this->config['password'], 1)) {
            throw new KantException(sprintf('Can not connect to MySQL server or cannot use database.%s', mysql_error()));
        }
        if ($this->version() > '4.1') {
            $charset = isset($this->config['charset']) ? $this->config['charset'] : '';
            $serverset = $charset ? "character_set_connection='$charset',character_set_results='$charset',character_set_client=binary" : '';
            $serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',') . " sql_mode='' ") : '';
            $serverset && mysql_query("SET $serverset", $this->dbh);
        }

        if ($this->config['database'] && !@mysql_select_db($this->config['database'], $this->dbh)) {
            throw new KantException(sprintf('Can not use MySQL server or cannot use database.%s', mysql_error()));
        }
        $this->database = $this->config['database'];
    }

    /**
     *
     * Get MySQL server info
     *
     * @return string the MySQL server version on success&return.falseforfailure;.
     */
    public function version() {
        if (!is_resource($this->dbh)) {
            $this->_connect();
        }
        return mysql_get_server_info($this->dbh);
    }

    /**
     * Free result memory
     */
    public function free() {
        if (is_resource($this->queryID)) {
            mysql_free_result($this->queryID);
        }
        $this->queryID = null;
{'fraction_non_alphanumeric': 0.17095310136157338, 'fraction_numerical': 0.006915928247244435, 'mean_word_length': 2.4901960784313726, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 54, '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': '6193344', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1350, 'n_words': 301}