title: Call to a member function fetch() on boolean
body: <p>I receive this error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function fetch() on boolean in
    C:\xampp\htdocs\repo\generator\model\database.php on line 34</p>
  </blockquote>
  
  <p>When I run this code:
      
  
  <pre><code>    class database
      {
          private $user = 'root';
          private $pass = '';
          public $pdo;
  
          public function connect() {
              try {
                  $this-&gt;pdo = new PDO('mysql:host=localhost; dbname=generatordatabase', $this-&gt;user, $this-&gt;pass);
                  echo 'Połączenie nawiązane!';
              }
              catch(PDOException $e) {
                  echo 'Połączenie nie mogło zostać utworzone: ' . $e-&gt;getMessage();
              }
          }
  
          public function createTable() {
  
                          $q = $this-&gt;pdo -&gt; query('SELECT * FROM article');
                            while($row = $q-&gt;fetch()) {
                                echo $row['id'].' ';
                            }
                            $q-&gt;closeCursor();
          }
      }
  
      ?&gt;
  </code></pre>