Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database{
- private $host = "localhost";
- private $db_name = "amg_db";
- private $username = "root";
- private $password = "";
- public $conn;
- public function getConnection(){
- $this->conn = null;
- try {
- $this->conn = new PDO("mysql:host=".$this->host.";dbname=".$this->db_name, $this->username, $this->password);
- } catch (PDOException $exception) {
- echo "Connection Error! ". $exception->getMessage();
- }
- return $this->conn;
- }
- }
- $database = new Database();
- $db = $database->getConnection();
- $query = "CREATE TABLE test (
- id INT(11)
- );";
- $stmt = $db->prepare($query);
- $stmt->execute();
- ?>
Add Comment
Please, Sign In to add comment