olshop/application/models/Barang.php

67 lines
1.2 KiB
PHP
Raw Normal View History

2020-01-02 23:12:35 +07:00
<?php
class Barang extends CI_Model{
//print_r($this->db->last_query());
function tambahbarang($data)
{
return $this->db->insert('barang',$data);
}
function barang_all()
{
$query = $this->db->get('barang');
//return $query->row();
return $query->result_array();
}
function barang_all2($limit,$offset)
{
$query = $this->db->get('barang',$limit,$offset);
//return $query->row();
return $query->result_array();
}
function barang_cust($where)
{
$this->db->where($where);
$query = $this->db->get('barang');
return $query->row();
}
function updatebarang($id,$data)
{
$this->db->where('id',$id);
return $this->db->update('barang',$data);
}
function deletebarang($id)
{
$this->db->where('id', $id);
return $this->db->delete('barang');
}
function caribarang($key)
{
$array = array('nama' => $key, 'kdbarang' => $key, 'tags' => $key);
$this->db->or_like($array);
$query = $this->db->get('barang');
return $query->result_array();
}
function barang_sold($id,$qty)
{
$this->db->set('stok', 'stok - ' . (int) $qty, FALSE);
$this->db->where('id', $id);
return $this->db->update('barang');
}
function baranglaris()
{
}
function barangbaru()
{
}
}
?>