-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimalClass.php
46 lines (46 loc) · 1.22 KB
/
AnimalClass.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
<?php
class AnimalClass
{
private $id;
function __construct($id)
{
$this->id = $id;
}
function getRarity()
{
$db = new DatabaseClass();
$result = mysql_query("SELECT rarity FROM animals WHERE id = $this->id");
$row = mysql_fetch_assoc($result);
return $row['rarity'];
}
function setRarity($rarity)
{
$db = new DatabaseClass();
mysql_query("UPDATE animals SET rarity = $rarity WHERE user_id = $this->id");
}
function getTypeID()
{
$db = new DatabaseClass();
$result = mysql_query("SELECT type FROM animals WHERE id = $this->id");
$row = mysql_fetch_assoc($result);
return $row['type'];
}
function getName()
{
$db = new DatabaseClass();
$result = mysql_query("SELECT name FROM animals WHERE id = $this->id");
$row = mysql_fetch_assoc($result);
return $row['name'];
}
function setName($name)
{
$db = new DatabaseClass();
mysql_query("UPDATE animals SET name = '$name' WHERE id = $this->id");
}
function deleteAnimal()
{
$db = new DatabaseClass();
mysql_query("DELETE FROM animals WHERE id = $this-id");
}
}
?>