<commit_before><?php namespace Silverplate\Form;

class Database {
    public static function make($dsn, $username, $password, $options) {
        $object = new static(new \PDO($dsn, $username, $password, $options));

        return $object;
    }

    public function __construct($pdo) {
        $this->pdo = $pdo;
    }

    public function save_form($form, $table) {
        $bindings = array();
        $keys = array();

        foreach($form as $field) {
            $keys[] = $field->key();
            $bindings[] = $field->get();
        }

        $fields = join(', ', $keys);
        $placeholders = rtrim(str_repeat('?, ', count($keys)), ', ');

        $query = "INSERT INTO $table ($fields) VALUES($placeholders)";

        $this->pdo->prepare($query)->execute($bindings);
    }
}<commit_msg>Database class - escaping database fields<commit_after><?php namespace Silverplate\Form;

class Database {
    public static function make($dsn, $username, $password, $options) {
        $object = new static(new \PDO($dsn, $username, $password, $options));

        return $object;
    }

    public function __construct($pdo) {
        $this->pdo = $pdo;
    }

    public function save_form($form, $table) {
        $bindings = array();
        $keys = array();

        foreach($form as $field) {
            $keys[] = "`$field->key()`";
            $bindings[] = $field->get();
        }

        $fields = join(', ', $keys);
        $placeholders = rtrim(str_repeat('?, ', count($keys)), ', ');

        $query = "INSERT INTO $table ($fields) VALUES($placeholders)";

        $this->pdo->prepare($query)->execute($bindings);
    }
}
{'fraction_non_alphanumeric': 0.18087697929354446, 'fraction_numerical': 0.0, 'mean_word_length': 2.548596112311015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '226747', 'n_tokens_mistral': 511, 'n_tokens_neox': 488, 'n_words': 112}