34 lines
859 B
PHP
34 lines
859 B
PHP
<?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);
|
|
}
|
|
} |