<commit_before><?php
//
// Function creates the table
//
function initTable() {
  // Connect to local DB and build the query
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "CREATE TABLE myfriends (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    firstname CHAR(15), lastname CHAR(30), num CHAR(15), age CHAR(3))";

  // Run the table creation query and then close connection
  mysqli_query($sqlconn, $sql);
  $sqlconn->close();
}


//
// Populate table from text file, false if table already has data
//
function popTable() {
  // Connect to local DB, hardcoded creds not recomended
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");

  // Open the file
  $inputFile = fopen("friends.txt", "r");
  while (($line = fgets($inputFile)) !== false) {
    // Raad line from file into array, then convert to a astring
    $lineArray = explode(',', $line);
    $line = settype($line, "string");

    // Insert values into table. ID is auto incremented. Skip if identical row
    $sql = "INSERT INTO myfriends (firstname, lastname, num, age)
      SELECT * FROM (SELECT '$lineArray[0]', '$lineArray[1]', '$lineArray[2]', '$lineArray[3]') AS tmp
      WHERE NOT EXISTS (SELECT firstname, lastname, num, age FROM myfriends
        WHERE firstname='$lineArray[0]' AND lastname='$lineArray[1]' AND num='$lineArray[2]' AND age='$lineArray[3]'
      LIMIT 1)";

    // Execute the query. Error handling can be added here later
    if ($sqlconn->query($sql) === TRUE) {
        continue;
    } else {
        continue;
    }
  }
  $sqlconn->close();
}


//
// Function returns an array containing all DB entries
//
function readTable() {
  // Connect to the database, build the query, execute
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "SELECT * FROM myfriends";
  $result = mysqli_query($sqlconn,$sql);
  $sqlconn->close();

  // Display query response
  echo "<p>Current Database Entries</p>";
  echo "<table><tbody>";
  echo "<tr><th>Id </th><th>First Name</th><th>Last Name</th><th>Phone Number</th><th>Age</th></tr>";
  while ($row = mysqli_fetch_assoc($result)) {
    echo "<tr>";
    echo "<td>", $row['id'], "</td>";
    echo "<td>", $row['firstname'], "</td>";
    echo "<td>", $row['lastname'], "</td>";
    echo "<td>", $row['num'], "</td>";
    echo "<td>", $row['age'], "</td>";
    echo "</tr>";
  }
  echo "</tbody></table>";
}


//
// function adds a row to the database
//
function addRow($fName, $lName, $pNum, $age) {
  $sqlconn = mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "INSERT INTO myfriends (firstname, lastname, num, age)
    SELECT * FROM (SELECT '$fName', '$lName', '$pNum', '$age') AS tmp
    WHERE NOT EXISTS (SELECT firstname, lastname, num, age FROM myfriends
      WHERE firstname='$lineArray[0]' AND lastname='$lineArray[1]' AND num='$lineArray[2]' AND age='$lineArray[3]'
    LIMIT 1)";
}



?><commit_msg>add addRow()<commit_after><?php
//
// Function creates the table
//
function initTable() {
  // Connect to local DB and build the query
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "CREATE TABLE myfriends (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    firstname CHAR(15), lastname CHAR(30), num CHAR(15), age CHAR(3))";

  // Run the table creation query and then close connection
  mysqli_query($sqlconn, $sql);
  $sqlconn->close();
}


//
// Populate table from text file, false if table already has data
//
function popTable() {
  // Connect to local DB, hardcoded creds not recomended
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");

  // Open the file
  $inputFile = fopen("friends.txt", "r");
  while (($line = fgets($inputFile)) !== false) {
    // Raad line from file into array, then convert to a astring
    $lineArray = explode(',', $line);
    $line = settype($line, "string");

    // Insert values into table. ID is auto incremented. Skip if identical row
    $sql = "INSERT INTO myfriends (firstname, lastname, num, age)
      SELECT * FROM (SELECT '$lineArray[0]', '$lineArray[1]', '$lineArray[2]', '$lineArray[3]') AS tmp
      WHERE NOT EXISTS (SELECT firstname, lastname, num, age FROM myfriends
        WHERE firstname='$lineArray[0]' AND lastname='$lineArray[1]' AND num='$lineArray[2]' AND age='$lineArray[3]'
      LIMIT 1)";

    // Execute the query. Error handling can be added here later
    if ($sqlconn->query($sql) === TRUE) {
        continue;
    } else {
        continue;
    }
  }
  $sqlconn->close();
}


//
// Function returns an array containing all DB entries
//
function readTable() {
  // Connect to the database, build the query, execute
  $sqlconn =  mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "SELECT * FROM myfriends";
  $result = mysqli_query($sqlconn,$sql);
  $sqlconn->close();

  // Display query response
  echo "<p>Current Database Entries</p>";
  echo "<table><tbody>";
  echo "<tr><th>Id </th><th>First Name</th><th>Last Name</th><th>Phone Number</th><th>Age</th></tr>";
  while ($row = mysqli_fetch_assoc($result)) {
    echo "<tr>";
    echo "<td>", $row['id'], "</td>";
    echo "<td>", $row['firstname'], "</td>";
    echo "<td>", $row['lastname'], "</td>";
    echo "<td>", $row['num'], "</td>";
    echo "<td>", $row['age'], "</td>";
    echo "</tr>";
  }
  echo "</tbody></table>";
}


//
// function adds a row to the database
//
function addRow($fName, $lName, $pNum, $age) {
  $sqlconn = mysqli_connect("localhost", "root", "password", "<PASSWORD>");
  $sql = "INSERT INTO myfriends (firstname, lastname, num, age)
    SELECT * FROM (SELECT '$fName', '$lName', '$pNum', '$age') AS tmp
    WHERE NOT EXISTS (SELECT firstname, lastname, num, age FROM myfriends
      WHERE firstname='$lineArray[0]' AND lastname='$lineArray[1]' AND num='$lineArray[2]' AND age='$lineArray[3]'
    LIMIT 1)";

  $result = mysqli_query($sqlconn,$sql);
  $sqlconn->close();
}



?>
{'fraction_non_alphanumeric': 0.188, 'fraction_numerical': 0.007333333333333333, 'mean_word_length': 3.7778662420382165, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 82, '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': '4036144', 'n_tokens_mistral': 2035, 'n_tokens_neox': 1942, 'n_words': 598}