You've already forked codeigniter_test
first commit
This commit is contained in:
42
application/models/M_admin.php
Normal file
42
application/models/M_admin.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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'");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user