title: Call to undefined method PDO::setAttribute()
body: <pre><code>class dbConnection {
  public $pdo;
  public function __construct() {
      $this-&gt;dbConnect();
  }
  public function dbConnect() {
      if((count($_POST) == 6)&amp;&amp;($_GET['a'] == "connect")) {
          $host = $_POST['host'];
          $port = $_POST['port'];
          $username = $_POST['username'];
          $password = $_POST['password'];
          $database = $_POST['database']; 
          try{
                  $this-&gt;pdo = new PDO('mysql:host='.$host.';dbname='.$database.';port='.$port, $username, $password );
                  echo 'Connection successful!';
                  return $pdo;
          }
          catch(PDOException $e){
                  echo 'Error: ' . $e-&gt;getMessage();
          }   
      }
  }
  }
  
  class Group extends dbConnection { //Class for group, for ex. employe and employers.
  public $name;  // Name of group
  public $pdo;
  
  public function __construct ($_name, $conn) {
  $this-&gt;pdo = $conn;
  $this-&gt;name = $_name;
  
  }
  
  public function getGroupList() {
      if(isset($this-&gt;pdo)) {
          try
          {
              $conn = $this-&gt;pdo;
            $conn -&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //to catch exceptions
  
            $stmt = $pdo -&gt; query('SELECT id, Name, Skills FROM '.$this-&gt;name); //sql query with group name
            $list = $stmt-&gt;fetchAll(PDO::FETCH_NUM); //fetch statement into array
            $stmt -&gt; closeCursor();
            unset($stmt);
            return var_dump($list); //gives pure data
          }
          catch(PDOException $e) 
          {
            return 'There was some error: ' . $e-&gt;getMessage();
          }
      }
      else {
      $pdo;
      }
  }
  
  }
  </code></pre>
  
  <p>And execution:</p>
  
  <pre><code>$conn = new dbConnection;
  $workers = new Group("workers", $conn);
  $workers-&gt;getGroupList();
  </code></pre>
  
  <p>I get error:</p>
  
  <blockquote>
    <p>Call to undefined method dbConnection::setAttribute()
    on line:</p>
  </blockquote>
  
  <p><code>$conn -&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //to catch exceptions</code></p>
  
  <p>I'm trying to solve that, I don't know why php treats PDO object as a method. I don't have any idea. And I have to write more letters.</p>