55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
class Pembeli_model extends CI_Model
|
|
{
|
|
|
|
public function countall()
|
|
{
|
|
return $this->db->count_all('pembeli');
|
|
}
|
|
|
|
public function get_all_pembeli($sort = 'asc')
|
|
{
|
|
$this->db->order_by('id_pembeli', $sort);
|
|
return $this->db->get('pembeli');
|
|
}
|
|
|
|
public function get_pembeli($id_pembeli)
|
|
{
|
|
$this->db->join('pengguna', 'pengguna.id_pengguna=pembeli.id_pengguna', 'left');
|
|
$this->db->where('id_pembeli', $id_pembeli);
|
|
return $this->db->get('pembeli');
|
|
}
|
|
|
|
public function get_by_id_pengguna($id_pengguna)
|
|
{
|
|
$this->db->where('id_pengguna', $id_pengguna);
|
|
return $this->db->get('pembeli');
|
|
}
|
|
|
|
public function add_pembeli($params)
|
|
{
|
|
return $this->db->insert('pembeli', $params);
|
|
}
|
|
|
|
public function update_pembeli($id_pembeli, $params)
|
|
{
|
|
$this->db->where('id_pembeli', $id_pembeli);
|
|
return $this->db->update('pembeli', $params);
|
|
}
|
|
|
|
public function delete_pembeli($id_pembeli)
|
|
{
|
|
$this->db->where('id_pembeli', $id_pembeli);
|
|
return $this->db->delete('pembeli');
|
|
}
|
|
|
|
public function get_by_username($username)
|
|
{
|
|
$this->db->where('username', $username);
|
|
return $this->db->get('pembeli');
|
|
}
|
|
}
|
|
?>
|