title: OOP PHP + PDO - Is this how it should be?
body: <p>I'm trying to create a simple example class before I start implementing the following into my projects and I would like to know if there is something I could/should improve. I will be very glad if someone gives me some input of how am I doing now.</p>
  
  <p>Simple class example:</p>
  
  <pre><code>  // define class
    class User{
    private $UserID;
    private $UserName;
    private $Email;
  
    function SetUserID($NewUserID){
      $this -&gt; UserID = $NewUserID;
      }
  
    function GetUserID(){
      return $this -&gt; UserID;
      }
  
    function SetUserName($NewUserName){
      // update object
      $this -&gt; UserName = $NewUserName;
      } 
  
    function GetUserName(){
      return $this -&gt; UserName;
      }
  
    function SetEmail($NewEmail){
      $this -&gt; Email = $NewEmail;          
      } 
  
    function GetEmail(){
      return $this -&gt; Email;
      }
  
    public function SaveUser(){
      // check if user exists
      $User = new User();
      if ($User-&gt;UserExists($this-&gt;UserID)){
        // user exists - update him
        $Pdo = new PDO('mysql:host=localhost;dbname=cms;charset=utf8', 'xxx', 'xxx');  
        $Query = $Pdo-&gt;prepare("Update User set UserName = :UserName, Email = :Email, UserID = :UserID where UserID = :UserID");
        $Query-&gt;bindValue(':UserName', $this-&gt;UserName);
        $Query-&gt;bindValue(':Email', $this-&gt;Email);
        $Query-&gt;bindValue('UserID', $this-&gt;UserID);
        $Query-&gt;execute();
        $Pro = null;
        }
      else{
        // insert new
        $Pdo = new PDO('mysql:host=localhost;dbname=cms;charset=utf8', 'xxx', 'xxx');  
        $Query = $Pdo-&gt;prepare("Insert into User (UserName, Email) values (:UserName, :Email)");
        $Query-&gt;bindValue(':UserName', $this-&gt;UserName);
        $Query-&gt;bindValue(':Email', $this-&gt;Email);
        $Query-&gt;execute();
        // close connection
        $Pdo = null; 
        }
      }
  
    private function UserExists($UserID){
      // returns true if users exists, false if not
      $Pdo = new PDO('mysql:host=localhost;dbname=cms;charset=utf8', 'root', 'vertrigo');
      $Query = $Pdo-&gt;prepare("SELECT * FROM User WHERE UserID=:UserID"); 
      $Query-&gt;bindValue(':UserID', $UserID);
      $Query-&gt;execute();
      $Row = $Query-&gt;fetch(PDO::FETCH_ASSOC);
      $Pdo = null;
  
      // get user
      if ($Row){
        return true;
        }
      else{
        return false;
        }
      }        
    }
  
  function GetUserInfo($UserID){
    // open pdo
    $Pdo = new PDO('mysql:host=localhost;dbname=cms;charset=utf8', 'root', 'vertrigo');  
    $Query = $Pdo-&gt;prepare("SELECT * FROM User WHERE UserID=:UserID");
    $Query-&gt;bindValue(':UserID', $UserID);
    $Query-&gt;execute();
    $Row = $Query-&gt;fetch(PDO::FETCH_ASSOC);
    $Pdo = null;
  
    // get UserInfo
    $UserInfo = new User();
    $UserInfo -&gt; SetUserID($UserID);
    $UserInfo -&gt; SetUserName($Row["UserName"]); 
    $UserInfo -&gt; SetEmail($Row["Email"]); 
  
    // return UserInfo
    return $UserInfo;
    }
  </code></pre>
  
  <p>This is just an basic example of how I would like to work with it. What do you think I should improve? </p>