Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Connection {
- public $connection;
- public $dbHost = 'localhost';
- public $dbName = 'employees';
- public $charset = 'charset=utf8';
- public $dbUser = 'root';
- public $dbPassword = '';
- public function __construct() {
- try {
- $this->connection = new PDO ("mysql:host=$this->dbHost;$this->dbName;$this->dbUser;
- $this->dbPassword");
- $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch (PDOException $e) {
- echo "There is something wrong with the database".$e->getMessage();
- }
- }
- function insertUserValues($tableName, $data) {
- $query = "INSERT INTO ".$tableName."(";
- $query .= implode (",",array_keys($data)).') VALUES (';
- $query .= "'" . implode ("','",array_values($data))."')";
- }
- }
- $users = new Connection();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement