Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. //...
  3.  
  4. // This will usually be received from an env variable, for example $connectionString = getenv('DB_URL');
  5. $connectionString = 'mysql://user:password@foo-bar.rds.amazonaws.com:3306/database';
  6.  
  7. // The values below will be your default values if $connectionString is empty.
  8. $dbConfig = array_merge(
  9. [
  10. 'host' => 'localhost',
  11. 'port' => 3306,
  12. 'user' => 'root',
  13. 'pass' => '',
  14. 'path' => 'wp', // DB_NAME
  15. ],
  16. array_filter(parse_url($connectionString))
  17. );
  18.  
  19. /** The name of the database for WordPress */
  20. define('DB_NAME', ltrim($dbConfig['path'], '/'));
  21.  
  22. /** MySQL database username */
  23. define('DB_USER', $dbConfig['user']);
  24.  
  25. /** MySQL database username */
  26. define('DB_PASSWORD', $dbConfig['pass']);
  27.  
  28. /** MySQL hostname */
  29. define('DB_HOST', "{$dbConfig['host']}:{$dbConfig['port']}");
  30.  
  31. //...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement