45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
use CodeIgniter\Model;
|
|
class AuditHistoryModel extends Model
|
|
{
|
|
protected $table = 'audit_history';
|
|
protected $primaryKey = 'id';
|
|
protected $allowedFields = ['module', 'business_id','is_add','is_edit', 'is_delete', 'current_data', 'old_data', 'created_on','created_by','updated_on','updated_by'];
|
|
|
|
public function saveData($data, $id = null)
|
|
{
|
|
if ($id === null) {
|
|
// Insert new record
|
|
return $this->db->table('audit_history')->insert($data);
|
|
} else {
|
|
// Update existing record
|
|
return $this->update($id, $data);
|
|
}
|
|
}
|
|
|
|
|
|
public function getData($table, $where = null,$whereIn = null)
|
|
{
|
|
$query = $this->db->table($table);
|
|
if ($where) {
|
|
$query->where($where);
|
|
}
|
|
if($whereIn){
|
|
// $query->whereIn($column_name,$missingValues)
|
|
$query->whereIn($whereIn[0],$whereIn[1]);
|
|
}
|
|
return $query->get()->getResult();
|
|
}
|
|
|
|
public function updateData($table, $data, $where)
|
|
{
|
|
$this->db->table($table)->update($data, $where);
|
|
$affected_rows = $this->db->affectedRows();
|
|
return $affected_rows;
|
|
}
|
|
|
|
|
|
|
|
}
|