Advertisement
Guest User

Untitled

a guest
Dec 14th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. $hostname = "localhost";
  3. $username = "mysqluser";
  4. $password = "mysqlpass";
  5. $database = "mysqldbname";
  6.  
  7. $strtedAt = microtime(true);
  8.  
  9. try {
  10. $conn = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
  11. // set the PDO error mode to exception
  12. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  13. echo "Connected successfully <br>";
  14. }
  15. catch(PDOException $e)
  16. {
  17. echo "Connection failed: " . $e->getMessage();
  18. }
  19.  
  20. $endedAt = microtime(true);
  21. $msc = $endedAt - $strtedAt;
  22.  
  23. echo "Time to mysql connect: " . $msc . ' s'; // in seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement