mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 18:27:16 +00:00
Improved MVC layout of code
This commit is contained in:
48
application/models/note.php
Normal file
48
application/models/note.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class Note extends CI_Model {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// Call the Model constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function list_all() {
|
||||
return $this->db->get('notes');
|
||||
}
|
||||
|
||||
function add() {
|
||||
$data = array(
|
||||
'cat' => $this->input->post('category'),
|
||||
'title' => $this->input->post('title'),
|
||||
'note' => $this->input->post('content')
|
||||
);
|
||||
|
||||
$this->db->insert('notes', $data);
|
||||
}
|
||||
|
||||
function edit() {
|
||||
$data = array(
|
||||
'cat' => $this->input->post('category'),
|
||||
'title' => $this->input->post('title'),
|
||||
'note' => $this->input->post('content')
|
||||
);
|
||||
|
||||
$this->db->where('id', $this->input->post('id'));
|
||||
$this->db->update('notes', $data);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
$this->db->delete('notes', array('id' => $id));
|
||||
}
|
||||
|
||||
function view($id) {
|
||||
// Get Note
|
||||
$this->db->where('id', $id);
|
||||
return $this->db->get('notes');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user