-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparks_migration.php
More file actions
49 lines (29 loc) · 1.07 KB
/
parks_migration.php
File metadata and controls
49 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// Constants///////////////////////////////////////////
// DB_HOST-the IP Address to connect to
define("DB_HOST", "127.0.0.1");
// DB_NAME-the Database to connect to
define("DB_NAME", "parks_db");
// DB_USER-the MYSQL User to use
define("DB_USER", "parks_user");
// DB_PASS-the password for the user to use
define("DB_PASS", "codeup");
// Requiring code to connect database, will be populated by constants
require_once('db_connect.php');
echo $dbc->getAttribute(PDO::ATTR_CONNECTION_STATUS) . "\n";
// Create the query and assign to var
$query = 'DROP TABLE IF EXISTS national_parks';
// Create the query and assign to var
$dbc->exec($query);
// Creating a second query to add the structure for the table
$queryTwo = 'CREATE TABLE national_parks (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
location VARCHAR(50) NOT NULL,
date_established DATE NOT NULL,
area_in_acres DOUBLE NOT NULL,
description TEXT NOT NULL,
PRIMARY KEY (id)
)';
$dbc->exec($queryTwo);
echo $dbc->getAttribute(PDO::ATTR_CONNECTION_STATUS) . "\n";