title: Can't insert into DB from object's method
body: <p>I try to get rid of procedural and switch to almost full OOP.
  I've made an abstract class 'Vehicle', and instantiated an extended one 'Car'.</p>
  
  <p>I've written an insert() method which insert datas in my database :
  I can't make it work !</p>
  
  <p>here's the abstract class :</p>
  
  <pre><code>    &lt;?php
  
  abstract class Vehicle
  {
      private $id;
      private $marque;
      private $model;
      private $imma;
  
      protected function __construct($ma, $mo, $im)
      {
          $this-&gt;marque = $ma;
          $this-&gt;model = $mo;
          $this-&gt;imma = $im;
      }
  
      public function setMarque($ma)
      {
          $this-&gt;marque = $ma;
      }
  
      public function setModel($mo)
      {
          $this-&gt;model = $mo;
      }
  
      public function setImma($im)
      {
          $this-&gt;imma = $im;
      }
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
      public function getMarque()
      {
          return $this-&gt;marque;
      }
  
      public function getModel()
      {
          return $this-&gt;model;
      }
  
      public function getImma()
      {
          return $this-&gt;imma;
      }
  
      public function insert(PDO $bdd, $idA)
      {
  
          try{
              $bdd-&gt;prepare('INSERT INTO vehicle (immatriculation, id_a)
                              VALUES ("'.$this-&gt;imma.'",'.$idA.')')-&gt;execute();
  
          }
          catch(Exception $e) {
              echo '&lt;script&gt;alert("An error has occured, try again...");&lt;/script&gt;';
              return;
          }
          $this-&gt;id =
              $bdd-&gt;prepare('SELECT id_vehicle FROM vehicle 
                             WHERE immatriculation="'.$this-&gt;imma.'"')-&gt;execute();
      }
  
  
  }
  </code></pre>