asdlkif
This commit is contained in:
@@ -14,12 +14,20 @@ class NoteModel
|
||||
{
|
||||
$database = DatabaseFactory::getFactory()->getConnection();
|
||||
|
||||
$sql = "SELECT user_id, note_id, note_text FROM notes WHERE user_id = :user_id";
|
||||
$sql = "SELECT note_id, note_text, note_timestamp FROM notes WHERE user_id = :user_id ORDER BY note_timestamp DESC";
|
||||
$query = $database->prepare($sql);
|
||||
$query->execute(array(':user_id' => Session::get('user_id')));
|
||||
|
||||
// fetchAll() is the PDO method that gets all result rows
|
||||
return $query->fetchAll();
|
||||
$notes = $query->fetchAll();
|
||||
|
||||
// Add markdown HTML to each note
|
||||
require_once __DIR__ . '/../libs/SimpleMarkdown.php';
|
||||
foreach ($notes as &$note) {
|
||||
$note->note_html = SimpleMarkdown::parse($note->note_text);
|
||||
}
|
||||
|
||||
return $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,13 +37,21 @@ class NoteModel
|
||||
*/
|
||||
public static function getNote($note_id)
|
||||
{
|
||||
$database = DatabaseFactory::getFactory()->getConnectionWithMySQLI();
|
||||
$database = DatabaseFactory::getFactory()->getConnection();
|
||||
|
||||
$sql = "SELECT user_id, note_id, note_text FROM notes WHERE user_id = :user_id AND note_id = :note_id LIMIT 1";
|
||||
$sql = "SELECT note_id, note_text, note_timestamp FROM notes WHERE user_id = :user_id AND note_id = :note_id LIMIT 1";
|
||||
$query = $database->prepare($sql);
|
||||
$query->execute(array(':user_id' => Session::get('user_id'), ':note_id' => $note_id));
|
||||
|
||||
return $query;
|
||||
$result = $query->fetch();
|
||||
|
||||
// Add markdown HTML
|
||||
if ($result) {
|
||||
require_once __DIR__ . '/../libs/SimpleMarkdown.php';
|
||||
$result->note_html = SimpleMarkdown::parse($result->note_text);
|
||||
}
|
||||
|
||||
return $result ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user