title: PHP I have a database connect file, should i put my database querie functions in the same file
body: <p>to explain my question better, i have two files: dbh.inc.php</p>
  
  <pre><code>$dbServername = "localhost";
  $dbUsername = "xxxxx";
  $dbPassword = "secret";
  $dbName = "databasename";
  
  $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
  mysqli_set_charset($conn,"utf8");
  
  if (!$conn) {
    die("Connection failed: ".mysqli_connect_error());
  }
  
  $table1 = "users";//1
  $table2 = "userprofile";//2
  $table3 = "twofactorauth";//3
  </code></pre>
  
  <p>And: database-query.func.php</p>
  
  <pre><code>function selectdb($data, $values, $url) {
    include ('dbh.inc.php');
    extract($data);
    extract($values);
    switch ($data['table']) {
      case '1':
      $table = $table1;
      break;
      case '2':
      $table = $table2;
      break;
      case '3':
      $table = $table3;
      break;
    }
    $sql = "SELECT $rows FROM $table WHERE $where;";
    print_r($sql);
    die();
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_prepare($stmt, $sql)) {
      mysqli_stmt_close($stmt);
      mysqli_close($conn);
      header("Location: ".$url."?error=sqlerror");
      die();
    } else {
      $amount = str_repeat('s', count($values));
      $values = array_values($values);
      mysqli_stmt_bind_param($stmt, $amount, ...$values);
      mysqli_stmt_execute($stmt);
      $result = mysqli_stmt_get_result($stmt);
      $getResult = mysqli_fetch_assoc($result);
      mysqli_stmt_close($stmt);
      mysqli_close($conn);
      $new = array_push($getResult, 'true');
      return $getResult;
    }
  }
  </code></pre>
  
  <p>So the first holds database connection, and the latter has dynamic querys for insert, update and select for the moment. And i am wondering should i combine the two files, to one. Since every time i need my connect i always use one of my querys and same on the other way around?</p>
  
  <p>Also 2 bonus questions: as you see in my connect file i have my table names and i use numbers in my other files and in the functions connect numbers to names.
  Lastly should i use PDO, why?</p>