title: How to use PHP prepared statements in OOP
body: <p>I am saving my data using this code (pasting my code)</p>
  
  <p>Connection.php: </p>
  
  <pre><code>&lt;?php
      namespace Database;
      use Mysqli;
  
      class Connection {
          public $con;
  
          function __construct() {
              $this-&gt;con = new mysqli(connection strings here);
          }
  
          function save($sql) {
              $this-&gt;con-&gt;query($sql);
          }
      }
  ?&gt;
  </code></pre>
  
  <p>then my Save.php is like this:</p>
  
  <pre><code>&lt;?php
      require 'config.php';
  
      class Save {
          function __construct($username, $password) {
              $connect = new Database\Connection;
              $sql = "INSERT INTO sample(string1, string2) VALUES ('$test1', '$test2')";
              $connect-&gt;save($sql);
          }
      }
  
      $save = new Save("last", "last");
  ?&gt;
  </code></pre>
  
  <p>my question is how do I implement bind params here and prepared statement for PHP?</p>
  
  <p>and also I would like to ask what are the best way to do this and best practices that I should implement for my code</p>
  
  <p>thanks guys</p>