db_provider.php 462 B

123456789101112131415161718192021
  1. <?php
  2. class DBProvider {
  3. function connect()
  4. {
  5. global $DB_NAME;
  6. global $DB_HOST;
  7. global $DB_USER;
  8. global $DB_PASSWD;
  9. $dns = "mysql:host={$DB_HOST};dbname={$DB_NAME}";
  10. return new PDO($dns, $DB_USER, $DB_PASSWD);
  11. }
  12. function connect_with_param($host, $user, $passwd, $dbname)
  13. {
  14. $dns = "mysql:host={$host};dbname={$dbname}";
  15. return new PDO($dns, $user, $passwd);
  16. }
  17. }