EVOLUTION-NINJA
Edit File: contents12.php
<?php namespace App\Models\Admin; use CodeIgniter\Model; class contents12 extends Model { protected $table = 'subject_materials'; protected $primaryKey = 'material_id'; protected $allowedFields = [ 'material_count', 'chapter_id', 'topic_id', 'sub_domain_id', 'domain_id', 'image', 'pdf', 'approval_status', 'return_status', 'delete_status', 'created_by', 'created_at', ]; public function get_where_row($domain_table, $where_domain) { $db = \Config\Database::connect(); // Get the database connection $builder = $db->table($domain_table); $builder->select('*'); $builder->where($where_domain); $query = $builder->get(); return $query->getRow(); } public function get_whererow($login_table, $where_id) { $db = \Config\Database::connect(); // Get the database connection $builder = $db->table($login_table); $builder->select('*'); $builder->where($where_id); $query = $builder->get(); return $query->getRow(); } public function insert_data($table, $data) { $this->table = $table; // Set the table name $this->insert($data); // Insert the data into the specified table return $this->getInsertID(); } // public function insert_data($table, $data) // { // // Ensure that the provided table name matches the model's table // if ($table !== 'sub_domains') { // return false; // Table name mismatch, return false or handle accordingly // } // // Insert the data into the table // $this->insert($data); // // Check if the insertion was successful // if ($this->affectedRows() > 0) { // return true; // Insertion successful // } else { // return false; // Insertion failed // } // } public function get_where_result($table, $where) { $builder = $this->db->table($table); $builder->select('*'); $builder->where($where); $query = $builder->get(); return $query->getResult(); } public function get_where_orderby_row($table, $where, $order_by) { $db = \Config\Database::connect(); // Get the database connection $builder = $db->table($table); $builder->select('*'); $builder->where($where); $builder->orderBy($order_by, 'DESC'); $query = $builder->get(); return $query->getRow(); } }