HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/nt/application/models/admin/Mmodule.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Mmodule extends CI_Model {

    public function __construct() {
        parent::__construct();

    }

    public function get_active_parks() {
        // Select active industrial parks from the database
        $this->db->select('industrial_park_id, park_name');
        $this->db->where('is_active', 1);
        $query = $this->db->get('industrial_park_master');

        // Return the result as an array
        return $query->result_array();
    }

      public function saveModule($data) {
        $this->db->insert('module_master', $data);
        return $this->db->insert_id();
    }

    public function getModuleData() {
        // Select required fields from plot_header and industrial_park_master tables
        $this->db->select('module_master.*, industrial_park_master.park_name');
        $this->db->from('module_master');
        $this->db->join('industrial_park_master', 'module_master.industrial_park_id = industrial_park_master.industrial_park_id');
        $this->db->order_by('module_master.module_id', 'DESC');
        // Get plot data
        $query = $this->db->get();
    
        // Return results as array
        return $query->result_array();
    }

    public function getmoduleDetails($moduleId) {
        // Join plot_header with industrial_park_master to get park_name
        $this->db->select('module_master.*, industrial_park_master.park_name,uom_master.name as uom_name');
        $this->db->from('module_master');
        $this->db->join('industrial_park_master', 'module_master.industrial_park_id = industrial_park_master.industrial_park_id');
        $this->db->join('uom_master', 'module_master.uom_id = uom_master.uom_id');
        $this->db->where('module_master.module_id', $moduleId);
        $plotDetails = $this->db->get()->row_array();
        return $plotDetails;
    }
    
    public function updateModule($moduleId, $moduleHeaderData) {
        // Update plot header details with the specified plot header ID
        $this->db->where('module_id', $moduleId);
        $this->db->update('module_master', $moduleHeaderData);
    } 
    
}