Guest User

Untitled

a guest
Aug 24th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. $dsn = 'mysql:host=localhost;dbname=DBNAME';
  2. $username = 'USER';
  3. $password = 'PASS';
  4. $options = array();
  5.  
  6. $dbh = new PDO($dsn, $username, $password, $options);
  7.  
  8. if ($dbh) {
  9.  
  10. $stmt = $dbh->query('SELECT * FROM MYTABLE LIMIT 1');
  11. $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
  12.  
  13. print_r($results);
  14.  
  15. }
  16. else {
  17. echo 'Failed.';
  18. }
  19.  
  20. [client]
  21.  
  22. default-character-set = utf8 # not utf8mb4
  23.  
  24. [mysql]
  25.  
  26. default-character-set = utf8 # not utf8mb4
  27.  
  28. [mysqld]
  29.  
  30. # REF: http://stackoverflow.com/a/24487309/3174018
  31. collation-server = utf8_unicode_ci
  32. character-set-server = utf8 # not utf8mb4
Add Comment
Please, Sign In to add comment