-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
joelsalisbury
committed
Dec 7, 2016
1 parent
97b1c1e
commit 91d83f7
Showing
2 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
<?php | ||
require_once 'database.php'; | ||
class Antibiotic { | ||
|
||
class Diagnosis | ||
protected $id; | ||
protected $name; | ||
protected $notes; | ||
protected $relatedAntibiotics; | ||
|
||
public function __construct($id=0) { | ||
if ($id !== 0) { | ||
$db = getDatabase(); | ||
$query = $db->prepare( "SELECT * from antibiotic WHERE id = :id " ); // return all fields (*) from the table WHERE the id is the var $id passed to the function | ||
$query->bindParam( ':id', $id ); | ||
$query->execute(); // Run the SQL query on our database | ||
$query->setFetchMode( PDO::FETCH_OBJ ); // A PHP method to tell the database we want to return all the data as objects with each table represented as a property of that object. This will be the case for most of our calls that return information from the database. http://php.net/manual/en/pdo.constants.php | ||
$data = $query->fetchAll(); | ||
|
||
$data = $data[0]; | ||
|
||
// Build our local object | ||
$this->id = $data->id; | ||
$this->name = $data->name; | ||
$this->notes = $data->notes; | ||
} | ||
} | ||
|
||
|
||
public function get () { | ||
$res['id'] = $this->id; | ||
$res['name'] = $this->name; | ||
$res['notes'] = $this->notes; | ||
|
||
return $res; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters