| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | <?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( | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 			'cat' => xss_clean($this->input->post('category')), | 
					
						
							|  |  |  | 			'title' => xss_clean($this->input->post('title')), | 
					
						
							|  |  |  | 			'note' => xss_clean($this->input->post('content')) | 
					
						
							| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->db->insert('notes', $data);  | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function edit() { | 
					
						
							|  |  |  | 		$data = array( | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 			'cat' => xss_clean($this->input->post('category')), | 
					
						
							|  |  |  | 			'title' => xss_clean($this->input->post('title')), | 
					
						
							|  |  |  | 			'note' => xss_clean($this->input->post('content')) | 
					
						
							| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 		$this->db->where('id', xss_clean($this->input->post('id'))); | 
					
						
							| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | 		$this->db->update('notes', $data);  | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function delete($id) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 		$this->db->delete('notes', array('id' => xss_clean($id)));  | 
					
						
							| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function view($id) { | 
					
						
							|  |  |  | 		// Get Note
 | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 		$this->db->where('id', xss_clean($id));  | 
					
						
							| 
									
										
										
										
											2011-07-22 08:08:47 +08:00
										 |  |  | 		return $this->db->get('notes'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |