forked from ttoponce/assignment-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmySQL.php
62 lines (44 loc) · 1.86 KB
/
mySQL.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
<?php
// database functions ************************************************
//include "dbConnect.php";
function fInsertToDatabase($myDB, $asin, $actorID){
$image = 'http://images.amazon.com/images/P/'. $asin .'.01.MZZZZZZZ.jpg';
// $sql = $myDB->prepare("INSERT INTO dvdtitles (asin, title, price) VALUES ('$asin', '$title', $price)");
// $sql->execute();
$sql = $myDB->prepare("INSERT INTO actor_title (asin, actorID) VALUES ('$asin', '$actorID')");
$sql->execute();
// $sql = $myDB->prepare("INSERT INTO dvdActors (fname, lname) VALUES ('$fname2', '$lname2')");
// $sql->execute();
echo'<img src='.$image.'>';
}
function fDeleteFromDatabase($myDB, $asin, $actorID) {
//$sql = "DELETE FROM dvdtitles WHERE price=$deleteID";
// TODO: Fill in the rest of the fuction
$sql = $myDB->prepare("DELETE FROM actor_title WHERE asin=:asinid AND actorID=:actorid");
$sql->bindValue(':asinid', $asin, PDO::PARAM_STR);
$sql->bindValue(':actorid', $actorID, PDO::PARAM_INT);
$sql->execute();
// $sql = $myDB->prepare("DELETE FROM dvdActors WHERE actorID=:id");
// $sql->bindValue(':id', $actor1, PDO::PARAM_STR);
// $sql->execute();
//
// $sql = $myDB->prepare("DELETE FROM dvdActors WHERE actorID=:id");
// $sql->bindValue(':id', $actor2, PDO::PARAM_STR);
// $sql->execute();
//$myDB->exec($sql);
}
function fListFromDatabase($myDB) {
$sql = $myDB->prepare("SELECT * FROM dvdActors INNER JOIN actor_title on dvdActors.actorID = actor_title.actorID INNER JOIN dvdtitles on actor_title.asin = dvdtitles.asin");
$sql->execute();
while($row = $sql->fetch()){
print_r($row);
//echo '<img src='.$image.'>';
}
// $sql = $myDB->prepare("SELECT * FROM dvdActors");
// $sql->execute();
// while($row = $sql->fetch()){
// print_r($row);
// //echo '<img src='.$image.'>';
// }
}
?>