You've already forked codeigniter_test
							
							
		
			
	
	
		
			42 lines
		
	
	
		
			996 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			42 lines
		
	
	
		
			996 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								class M_admin extends CI_Model{
							 | 
						||
| 
								 | 
							
								 
							 | 
						||
| 
								 | 
							
								    function get_post_all()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $query=$this->db->query("SELECT * FROM post ORDER BY id DESC");
							 | 
						||
| 
								 | 
							
								        return $query->result();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
									
							 | 
						||
| 
								 | 
							
									function save_post()
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										$simpan_data=array(
							 | 
						||
| 
								 | 
							
								            'post_title'  => $this->input->post('title'),
							 | 
						||
| 
								 | 
							
								            'post_content'      => $this->input->post('content'),
							 | 
						||
| 
								 | 
							
								       );
							 | 
						||
| 
								 | 
							
								        $simpan = $this->db->insert('post', $simpan_data);
							 | 
						||
| 
								 | 
							
								        return $simpan;
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									
							 | 
						||
| 
								 | 
							
									function edit_post($id)
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										$q="SELECT * FROM  post WHERE id='$id'";
							 | 
						||
| 
								 | 
							
								        $query=$this->db->query($q);
							 | 
						||
| 
								 | 
							
								        return $query->row();
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									
							 | 
						||
| 
								 | 
							
									function save_edit_post($id, $judul, $isi)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $data = array(
							 | 
						||
| 
								 | 
							
								            'id'        => $id,
							 | 
						||
| 
								 | 
							
								            'post_title'			 => $judul,
							 | 
						||
| 
								 | 
							
								            'post_content'       	 => $isi
							 | 
						||
| 
								 | 
							
								        );
							 | 
						||
| 
								 | 
							
								        $this->db->where('id', $id);
							 | 
						||
| 
								 | 
							
								        $this->db->update('post', $data);    
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
									
							 | 
						||
| 
								 | 
							
									function delete_post($id)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $query=$this->db->query("DELETE FROM post WHERE id='$id'");
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |