<commit_before><?php

abstract class EmmaModel implements Model {
    
    static $instance;
    
    public $db;

    public function __construct () {}
    
    public function query ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die (var_dump ($this->db->connection->errorInfo ()));

    }

    public function oldFetch ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result = $stmt->fetch (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die (var_dump ($this->db->connection->errorInfo ()));

        return $result;

    }

    public function oldFetchAll ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die (var_dump ($this->db->connection->errorInfo ()));

        return $result;

    }

    public function fetch ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result     = $stmt->fetch (PDO::FETCH_ASSOC);
        $result_col = $stmt->fetch (PDO::FETCH_COLUMN);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die (var_dump ($this->db->connection->errorInfo ()));

        //Send single data object
        return DataObject::getInstance ($result);
        
    }
    
    public function fetchAll ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $results = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die (var_dump ($this->db->connection->errorInfo ()));

        $data_objects = array ();
        foreach ($results as $result) {

            array_push ($data_objects, DataObject::getInstance ($result));

        }

        //Send all data objects in an array
        return $data_objects;
        
    }
    
}
<commit_msg>Additional model functionallity and error messaging.<commit_after><?php

abstract class EmmaModel implements Model {
    
    static $instance;
    
    public $db;

    public function __construct () {}
    
    public function query ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die ($this->db->connection->errorInfo ());

    }

    public function oldFetch ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result = $stmt->fetch (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die ($this->db->connection->errorInfo ());

        return $result;

    }

    public function oldFetchAll ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die ($this->db->connection->errorInfo ());

        return $result;

    }

    public function fetch ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $result     = $stmt->fetch (PDO::FETCH_ASSOC);
        $result_col = $stmt->fetch (PDO::FETCH_COLUMN);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die ($this->db->connection->errorInfo ());

        //Send single data object
        return DataObject::getInstance ($result);
        
    }
    
    public function fetchAll ($query, $params = NULL) {

        if (DEBUG_MODE) $this->db->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $this->db->connection->prepare ($query);
        $stmt->execute ($params);
        $results = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $stmt->closeCursor ();

        if (DEBUG_MODE)
            if ($this->db->connection->errorInfo ()[0] != "00000")
                die ($this->db->connection->errorInfo ());

        $data_objects = array ();
        foreach ($results as $result) {

            array_push ($data_objects, DataObject::getInstance ($result));

        }

        //Send all data objects in an array
        return $data_objects;
        
    }

    protected function generateSalt () {

        return sha1 (openssl_random_pseudo_bytes (100));

    }

    protected function encrypt ($string) {

        return sha1 ($string);

    }
    
}

{'fraction_non_alphanumeric': 0.16487171365220146, 'fraction_numerical': 0.010294583465315173, 'mean_word_length': 2.4451718494271684, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 151, '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': '5750301', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1823, 'n_words': 378}