<commit_before><?php
  require_once 'db_config.php';
  /**
  * singleton to connect db.
  */
  class SqlManager {
    private static $instance = null; // Hold the class instance.
    private $conn, $query, $error, $result, $numItemsReturned;

    /**
    * The db connection is established in the private constructor.
    */
    private function __construct() {
      try {
        $this->conn = new PDO('mysql:host=' . HOST . ';dbname=' . DATABASE, USER, PASSWORD); // creating db connection
        $this->error = false;
        $this->numItemsReturned = 0;
      } catch(PDOException $e) {
        die("Connection failed: " . $e->getMessage());
      }
    }

    /**
    * Gets the instance of the SqlManager
    * @return SqlManager gets the single instance
    */
    public static function getInstance() {
      if(!isset(self::$instance)) {
        self::$instance = new SqlManager();
      }
      return self::$instance;
    }

    /**
    *
    */
    public function query($sql, $params = array()) {
      $this->error = false;
      if ($this->query = $this->conn->prepare($sql)) {
        $index = 1;
        if (count($params) > 0) {
          foreach($params as $param) {
            $this->query->bindValue($index, $param);
            $index++;
          }
        }
        if ($this->query->execute()) {
          $this->result = $this->query->fetchAll(PDO::FETCH_OBJ);
          $this->numItemsReturned = $this->query->rowCount();
        } else {
          $this->error = true;
        }
      }
      return $this;
    }

    /**
    * Gets the result from the last query executed
    * @return array Objects from database
    */
    public function getResult() {
      return $this->result;
    }

    /**<commit_msg>added line to help debug<commit_after><?php
  require_once 'db_config.php';
  /**
  * singleton to connect db.
  */
  class SqlManager {
    private static $instance = null; // Hold the class instance.
    private $conn, $query, $error, $result, $numItemsReturned;

    /**
    * The db connection is established in the private constructor.
    */
    private function __construct() {
      try {
        $this->conn = new PDO('mysql:host=' . HOST . ';dbname=' . DATABASE, USER, PASSWORD); // creating db connection
        $this->error = false;
        $this->numItemsReturned = 0;
      } catch(PDOException $e) {
        die("Connection failed: " . $e->getMessage());
      }
    }

    /**
    * Gets the instance of the SqlManager
    * @return SqlManager gets the single instance
    */
    public static function getInstance() {
      if(!isset(self::$instance)) {
        self::$instance = new SqlManager();
      }
      return self::$instance;
    }

    /**
    *
    */
    public function query($sql, $params = array()) {
      $this->error = false;
      if ($this->query = $this->conn->prepare($sql)) {
        $index = 1;
        if (count($params) > 0) {
          foreach($params as $param) {
            $this->query->bindValue($index, $param);
            $index++;
          }
        }
        if ($this->query->execute()) {
          $this->result = $this->query->fetchAll(PDO::FETCH_OBJ);
          $this->numItemsReturned = $this->query->rowCount();
        } else {
          // NOTE: for debugging
          // print_r($this->query->errorInfo());
          $this->error = true;
        }
      }
      return $this;
    }

    /**
    * Gets the result from the last query executed
    * @return array Objects from database
    */
    public function getResult() {
      return $this->result;
    }

    /**
{'fraction_non_alphanumeric': 0.15076923076923077, 'fraction_numerical': 0.0016783216783216783, 'mean_word_length': 2.007569386038688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, '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': '1963151', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1045, 'n_words': 264}