You've already forked ci_restful
first commit
This commit is contained in:
40
application/models/barang_model.php
Normal file
40
application/models/barang_model.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
class barang_model extends CI_Model{
|
||||
|
||||
function get_barang_all()
|
||||
{
|
||||
$query=$this->db->query("SELECT * FROM barang ORDER BY id DESC");
|
||||
return $query->result();
|
||||
}
|
||||
function get_barang_by($id){
|
||||
$query=$this->db->query("SELECT * FROM barang WHERE id='$id'");
|
||||
return $query->result();
|
||||
}
|
||||
function update_barang($id)
|
||||
{
|
||||
$q="SELECT * FROM barang WHERE id='$id'";
|
||||
$query=$this->db->query($q);
|
||||
return $query->row();
|
||||
}
|
||||
function simpan_update_barang($id, $nama, $harga)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
'nama' => $nama,
|
||||
'harga' => $harga
|
||||
);
|
||||
$this->db->where('id', $id);
|
||||
$this->db->update('barang', $data);
|
||||
}
|
||||
|
||||
function delete_barang($id)
|
||||
{
|
||||
$query=$this->db->query("DELETE FROM barang WHERE id='$id'");
|
||||
}
|
||||
|
||||
function simpan_barang($simpan_data)
|
||||
{
|
||||
$this->db->insert('barang', $simpan_data);
|
||||
return $this->db->affected_rows();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user