<commit_before><?php
class DB {
  static protected $link;
  static protected $prepared_queries = array();

  static private function connect(){
    $c = Configuration::get('database');
        /* Connect to an ODBC database using driver invocation */
    $dsn = $c['dsn'];
    $user = $c['username'];
    $password = $c['password'];

    $dbh = new PDO($dsn, $user, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);//drops exception when error
    if ($dbh->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,TRUE);//necesary for not hanging mysql
    }
    
    self::$link = $dbh;
  }

  static public function get_pdolink(){
      if(!self::$link)
    self::connect();
      return self::$link;
  }

  //static private function close(){
  //    unset(self::$link);
  //}


  static public function query($sql,$params=array(),$bind_params=array(),$class_name = 'stdClass'){
    if(!self::$link)
    self::connect();
    

    $return = array();<commit_msg>set utf8 character set as default for DB connections<commit_after><?php
class DB {
  static protected $link;
  static protected $prepared_queries = array();

  static private function connect(){
    $c = Configuration::get('database');
        /* Connect to an ODBC database using driver invocation */
    $dsn = $c['dsn'];
    $user = $c['username'];
    $password = $c['password'];

    $dbh = new PDO($dsn, $user, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);//drops exception when error
    if ($dbh->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,TRUE);//necesary for not hanging mysql
    }
    
    self::$link = $dbh;
    //self::query("SET NAMES 'UTF-8'");
    self::execute("SET NAMES utf8");
  }

  static public function get_pdolink(){
      if(!self::$link)
    self::connect();
      return self::$link;
  }

  //static private function close(){
  //    unset(self::$link);
  //}


  static public function query($sql,$params=array(),$bind_params=array(),$class_name = 'stdClass'){
    if(!self::$link)
    self::connect();
    

    $return = array();
{'fraction_non_alphanumeric': 0.17058823529411765, 'fraction_numerical': 0.0013574660633484162, 'mean_word_length': 3.6645569620253164, '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': '6473145', 'n_tokens_mistral': 724, 'n_tokens_neox': 721, 'n_words': 155}