Guest User

Untitled

a guest
Jan 25th, 2016
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $db_host = '127.0.0.1';
  4. $db_user = 'root';
  5. $db_pass = '';
  6. $db_name = 'mysql';
  7.  
  8. $conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
  9.  
  10. /*
  11. * A simple query works
  12. * Entry created in performance_schema.events_statements_summary_by_digest
  13. * DIGEST_TEXT: SELECT * FROM `mysql` . `user`
  14. */
  15. $conn->query('SELECT * FROM mysql.user');
  16.  
  17. /*
  18. * SQL prepared statements also work
  19. * Entries created in performance_schema.events_statements_summary_by_digest
  20. * DIGEST_TEXT: PREPARE `stmt` FROM ?
  21. * DIGEST_TEXT: EXECUTE `stmt`
  22. * DIGEST_TEXT: DROP PREPARE `stmt`
  23. */
  24. $conn->query('PREPARE stmt FROM "SELECT * FROM mysql.user"');
  25. $conn->query('EXECUTE stmt');
  26. $conn->query('DROP PREPARE stmt');
  27.  
  28. /*
  29. * C API statements do not work
  30. * No entry created in performance_schema.events_statements_summary_by_digest
  31. */
  32. $stmt = $conn->stmt_init();
  33. $stmt->prepare('SELECT * FROM mysql.user');
  34. $stmt->execute();
  35. $stmt->close();
RAW Paste Data