Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. class Connection {
  3. public $connection;
  4. public $dbHost = 'localhost';
  5. public $dbName = 'employees';
  6. public $charset = 'charset=utf8';
  7. public $dbUser = 'root';
  8. public $dbPassword = '';
  9.  
  10. public function __construct() {
  11. try {
  12. $this->connection = new PDO ("mysql:host=$this->dbHost;$this->dbName;$this->dbUser;
  13. $this->dbPassword");
  14. $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  15.  
  16. }
  17. catch (PDOException $e) {
  18. echo "There is something wrong with the database".$e->getMessage();
  19. }
  20. }
  21. function insertUserValues($tableName, $data) {
  22. $query = "INSERT INTO ".$tableName."(";
  23. $query .= implode (",",array_keys($data)).') VALUES (';
  24. $query .= "'" . implode ("','",array_values($data))."')";
  25. }
  26. }
  27. $users = new Connection();
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement