title: problem getting num_rows with PDO class in php
body: <p>I have just changed my database connection. I am not used to the PDO class or OOP yet. Anyway, I connect to the db like this: </p>
  
  <pre><code>        $dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME;
          try
          {
              $this-&gt;db = new PDO($dsn, DB_USER, DB_PASS);
          }
          catch ( Exception $e )
          {
              die ( $e-&gt;getMessage() );
          }
  </code></pre>
  
  <p>I am trying to get number of rows from this query: </p>
  
  <pre><code>    $ip = $this-&gt;ip(); 
      $sql = "SELECT `id` FROM `login_failed`
              WHERE `ip` = :ip AND `time` BETWEEN NOW( ) - INTERVAL 120 MINUTE AND NOW( )
              LIMIT 3";
      try 
      {
          $stmt = $this-&gt;db-&gt;prepare($sql);
          $stmt-&gt;bindParam(':ip', $ip, PDO::PARAM_STR);
          $result = $stmt-&gt;execute(); // $result = true
          $n = $stmt-&gt;num_rows ; // n = NULL?
          $stmt-&gt;closeCursor(); 
      }       
      catch (Exception $e)
      {
          die ($e-&gt;getMessage() ); 
      }
  </code></pre>
  
  <p>In <code>phpmyadmin</code> I get a result so my query is correct, but <code>$n</code> is <code>NULL</code> for some reason.. How do I get number of rows with <code>PDO</code></p>