Skip to content
Snippets Groups Projects
Commit 7388e206 authored by Tran Le's avatar Tran Le
Browse files

Lab17: Step5 completed (but not working)

parent 0db598f4
Branches
No related merge requests found
...@@ -30,16 +30,29 @@ class Blog_Entry_Table { ...@@ -30,16 +30,29 @@ class Blog_Entry_Table {
//SELECT 'columnName' AS 'aliasName' //SELECT 'columnName' AS 'aliasName'
//this is SQL Aliases: temporarily rename a table or column heading //this is SQL Aliases: temporarily rename a table or column heading
//so that it's more readable. //so that it's more readable.
$statement = $this->makeStatement($sql);
return $statement;
}
public function getEntry($id) {
$sql = "SELECT id, title, text, date_created FROM blog_entry WHERE entry_id = ?";
$data = $array($id);
$statement = $this->makeStatement($sql, $data);
$model = $statement->fetchObject();
return $model;
}
public function makeStatement($sql, $data=NULL) {
$statement = $this->db->prepare( $entrySQL ); $statement = $this->db->prepare( $entrySQL );
try{ try{
$statement->execute(); $statement->execute($data);
} catch (Exception $e){ } catch (Exception $e){
$msg = "<p>You tried to run this sql: $entrySQL<p> $exceptionMsg = "<p>You tried to run this sql: $entrySQL<p>
<p>Exception: $e</p>"; <p>Exception: $e</p>";
trigger_error($msg); trigger_error($exceptionMsg);
} }
return $statement; return $statement;
} }
} }
?> ?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment