50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
use CodeIgniter\Model;
|
|
class BooksModel extends Model
|
|
{
|
|
protected $table = 'causes';
|
|
protected $primaryKey = 'causes_id';
|
|
protected $allowedFields = ['causes_id','name','description', 'business_id', 'created_on','created_by','updated_on','updated_by','isactive'];
|
|
// protected $allowedFields = ['causes_id','title','cover_picture','publication_date','isbn_code','publisher','category','genre','language','description','page_count','tax','price','created_on','created_by','updated_on','updated_by','isactive','business_id'];
|
|
|
|
public function saveData($data, $id = null)
|
|
{
|
|
if ($id === null) {
|
|
// Insert new record
|
|
return $this->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 inactiveMissingDetails($table_name,$dataToUpdate,$where = null,$whereIn = null)
|
|
{
|
|
$this->db->table($table_name);
|
|
$query = $this->db->table($table_name);
|
|
if ($where) {
|
|
$query->where($where);
|
|
}
|
|
if ($whereIn) {
|
|
$query->whereIn($whereIn[0], $whereIn[1]);
|
|
}
|
|
return $query->update($dataToUpdate);
|
|
}
|
|
|
|
}
|