Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. try {
  3. require_once 'conf.php';
  4. $conn = mysqlConnector();
  5. $stmt = $conn->prepare('SELECT * FROM demo');
  6. $stmt->execute();
  7.  
  8. while($row = $stmt->fetch()) {
  9. print_r($row);
  10. }
  11.  
  12.  
  13. } catch(PDOException $e) {
  14. echo 'ERROR: ' . $e->getMessage();
  15. }
  16.  
  17. ?>
  18.  
  19. <?php
  20. define('DB_HOST', getenv('127.*.**.*'));
  21. define('DB_PORT',getenv('****'));
  22. define('DB_USER',getenv('admin4*****'));
  23. define('DB_PASS',getenv('databasePassword'));
  24. define('DB_NAME',getenv('ssh://5348030a***************@landbayscaling-innovifytest.rhcloud.com/~/git/landbayscaling.git/'));
  25.  
  26. function mysqlConnector(){
  27. $dsn = 'mysql:dbname='.DB_BASE.';host='.DB_HOST.';port='.DB_PORT;
  28. $dbh = new PDO($dsn, DB_USER, DB_PASS);
  29. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  30. return $dbh;
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement