title: PDO prepared equivalent statement for mysql_num_rows
body: <p>I hope this question does not seem vague but I am converting the old mysql statements to the PDO prepared statements and I have searched but cannot find the answer to this. What is the equivalent of <code>$count=mysql_num_rows($stmt);</code> in PDO? I have included my code so you can see what I am doing but basically I am creating a login page for users I have a PDO statement using <code>SELECT</code> to search the database for a matching username and password row. If it comes up with one then it will increase the <code>$count</code> variable to one so that my <code>IF</code> statment is true.</p>
  
  <p>CHECK_LOGIN.PHP</p>
  
  <pre><code>&lt;?php
  require 'functions.php';
  require 'DB.php';
  ob_start();
  
  // Define $myusername and $mypassword 
  $myusername=$_POST['myusername']; 
  $mypassword =$_POST['mypassword'];
  $mypassword = md5($_POST['mypassword']);
  
  checkLogin($conn,$myusername,$mypassword,$stmt);
  
  // Mysql_num_row is counting table row
  $count=mysql_num_rows($stmt);
  
  // If result matched $myusername and $mypassword, table row must be 1 row
  if($count==1){
  
  // Register $myusername, $mypassword and redirect to file "login_success.php"
      session_start();
      $_SESSION['myusername'] = $myusername;
      session_is_registered("myusername");
      session_is_registered("mypassword"); 
      $myusername1 = $_SESSION['myusername'];
      //UPDATE LAST LOGIN IN DATABASE
      date_default_timezone_set('America/Chicago');
      $last_login = date('m/d/Y h:i:s a', time());
      lastLogin($conn,$myusername1,$last_login);
      header("location:form.php");
  
  
  }
  else {
  
  echo "Wrong Username or Password";
  
  }
  ob_end_flush();
  ?&gt;
  </code></pre>
  
  <p>function in FUNCTION.PHP</p>
  
  <pre><code>function checkLogin($conn,$myusername,$mypassword,$stmt){
  
  $myusername = stripslashes($myusername);
  $myusername = mysql_real_escape_string($myusername);
  $stmt = $conn-&gt;prepare('SELECT * FROM `CLL_users` WHERE `user_name`=:myusername AND `password`=:mypassword');
  $stmt-&gt;execute(array(':myusername' =&gt; $myusername, ':mypassword' =&gt; $mypassword));
  }
  </code></pre>