46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelRaid extends CI_Model {
|
|
public function create($table, $data, $batch = false)
|
|
{
|
|
if($batch === false){
|
|
$insert = $this->db->insert($table, $data);
|
|
}else{
|
|
$insert = $this->db->insert_batch($table, $data);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function update($table, $data, $pk, $id = null, $batch = false)
|
|
{
|
|
if($batch === false){
|
|
$insert = $this->db->update($table, $data, array($pk => $id));
|
|
}else{
|
|
$insert = $this->db->update_batch($table, $data, $pk);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function delete($table, $data, $pk)
|
|
{
|
|
$this->db->where_in($pk, $data);
|
|
return $this->db->delete($table);
|
|
}
|
|
|
|
public function getDataRaid($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('raid a');
|
|
$this->db->join('spek b','b.RAID_ID=a.ID_RAID','left');
|
|
$this->db->group_by('a.ID_RAID');
|
|
}else{
|
|
$this->db->from('raid a');
|
|
$this->db->join('spek b','b.RAID_ID=a.ID_RAID','left');
|
|
$this->db->group_by('a.ID_RAID');
|
|
$this->db->where(['a.ID_RAID' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|
|
?>
|