-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsong.php
65 lines (48 loc) · 1.45 KB
/
song.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require_once __DIR__ . '/database.php';
class Song extends Database{
private $id;
private $title;
private $artist_id;
private $genre_id;
private $price;
public function __construct($title, $artist_id, $genre_id, $price){
parent::__construct();
$this->title = $title;
$this->artist_id = $artist_id;
$this->genre_id = $genre_id;
$this->price = $price;
}
public function setTitle($title){
$this->title = $title;
}
public function setArtistId($artist){
$this->artist_id = $artist;
}
public function setGenreId($genre_id){
$this->genre_id = $genre_id;
}
public function setPrice($price){
$this->price = $price;
}
public function save(){
$sql="
INSERT INTO songs (title, artist_id, genre_id, price, added)
VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP)
";
$statement = static::$pdo->prepare($sql);
$statement->bindParam(1, $this->title);
$statement->bindParam(2, $this->artist_id);
$statement->bindParam(3, $this->genre_id);
$statement->bindParam(4, $this->price);
$statement->execute();
$this->id = static::$pdo->lastInsertId();
}
public function getTitle(){
return $this->title;
}
public function getId(){
return $this->id;
}
}
?>