Part on DatabaseClass finished
This commit is contained in:
parent
0806411f09
commit
57abb48e63
2 changed files with 22 additions and 13 deletions
18
Database.php
Normal file
18
Database.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
// connect to MySQL database.
|
||||
class Database {
|
||||
public $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$dsn = "mysql:host=localhost;port=3306;dbname=myapp;charset=utf8mb4";
|
||||
$username = 'appUser';
|
||||
$password = 'password';
|
||||
$this->connection = new PDO($dsn, $username, $password);
|
||||
}
|
||||
public function query($query) {
|
||||
$statement = $this->connection->prepare($query);
|
||||
$statement->execute();
|
||||
return $statement;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue