[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
simaku-aset
/
application
/
models
/
[
Home
]
File: M_crud.php
<?php class M_crud extends CI_Model { var $tbl = ""; var $id = ""; function __construct() { parent::__construct(); } public function set($tbl = null, $id = 'id') { $this->tbl = $tbl; $this->id = $id; } function create($data = null) { $this->db->trans_begin(); $this->db->insert($this->tbl, $data); if ($this->db->trans_status() === FALSE) { return $this->db->trans_rollback(); } else { return $this->db->trans_commit(); } } function update($data = null, $id = null) { $this->db->trans_begin(); $this->db->where($this->id, $id); $this->db->update($this->tbl, $data); if ($this->db->trans_status() === FALSE) { return $this->db->trans_rollback(); } else { return $this->db->trans_commit(); } } function delete($id) { $this->db->trans_begin(); $this->db->where($this->id, $id); $this->db->delete($this->tbl); if ($this->db->trans_status() === FALSE) { return $this->db->trans_rollback(); } else { return $this->db->trans_commit(); } } function read() { return $this->db->get($this->tbl); } function read_where($val) { $this->db->where($val); return $this->db->get($this->tbl); } function readID($id) { return $this->db->get_where($this->tbl, array($this->id => $id)); } function read_join1($table1, $id, $sel) { $this->db->select("$this->tbl.*, $sel"); $this->db->join($table1, $table1 . '.id = ' . $this->tbl . '.' . $id); return $this->db->get($this->tbl); } function read_where_join1($val, $table1, $id, $sel) { $this->db->select("$this->tbl.*, $sel"); $this->db->join($table1, $table1 . '.id = ' . $this->tbl . '.' . $id); $this->db->where($val); return $this->db->get($this->tbl); } }