Advertisement
Skorpius

PDO rowCount

Jun 11th, 2022 (edited)
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2.  
  3.     //https://youtu.be/4kQqC3M3QXs
  4.     //This script once password and database name entered will return number of rows returned from DB
  5.     try{
  6.         $pdo = new pdo('mysql:host=localhost;dbname=test;charset=utf8','root','passwordHere');
  7.     }catch(PDOException $e){
  8.  
  9.         die('Connection Error: ' . $e->getMessage() );
  10.  
  11.     }
  12.  
  13.     //require_once("connection.php");
  14.  
  15.     $stmt = $pdo->prepare("SELECT * FROM tableNameHere");
  16.     $stmt->exeute();
  17.  
  18.     echo $stmt->rowCount();
  19.  
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement