You've already forked codeigniter_test2
first commit
This commit is contained in:
39
application/models/barang_model.php
Normal file
39
application/models/barang_model.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?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 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=array(
|
||||
'nama' => $this->input->post('nama_barang'),
|
||||
'harga' => $this->input->post('harga'),
|
||||
);
|
||||
$simpan = $this->db->insert('barang', $simpan_data);
|
||||
return $simpan;
|
||||
redirect('barang_controller/barang','refresh');
|
||||
}
|
||||
}
|
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>
|
24
application/models/user_model.php
Normal file
24
application/models/user_model.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
class User_model extends CI_Model{
|
||||
|
||||
function simpan_user()
|
||||
{
|
||||
$simpan_data=array(
|
||||
'nama_lengkap' => $this->input->post('nama_lengkap'),
|
||||
'username' => $this->input->post('username'),
|
||||
'password' => md5($this->input->post('password')),
|
||||
'email' => $this->input->post('email'),
|
||||
'alamat' => $this->input->post('alamat')
|
||||
);
|
||||
$simpan = $this->db->insert('user', $simpan_data);
|
||||
return $simpan;
|
||||
}
|
||||
function login($user,$pass)
|
||||
{
|
||||
$pass = md5($pass);
|
||||
$sql1 = "SELECT * FROM USER WHERE username = '$user' AND password = '$pass'";
|
||||
$rs = mysql_query($sql1);
|
||||
$r = mysql_num_rows($rs);
|
||||
if ($r=='1'){return true;}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user