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'");
|
||||
}
|
||||
}
|
34
application/models/M_post.php
Normal file
34
application/models/M_post.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
class M_post extends CI_Model{
|
||||
|
||||
function get_post_all($perPage,$uri)
|
||||
{
|
||||
//$query=$this->db->query("SELECT * FROM post ORDER BY id DESC");
|
||||
//return $query->result();
|
||||
$this->db->select('*');
|
||||
$this->db->from('post');
|
||||
$this->db->order_by('id','DESC');
|
||||
$getData = $this->db->get('', $perPage, $uri);
|
||||
if($getData->num_rows() > 0)
|
||||
{return $getData->result_array();}
|
||||
else{return null;}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
10
application/models/index.html
Normal file
10
application/models/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user