0

Im new on web I still learn using this CI platform. I want to know how to check connection to database that I choose from file "database.php" wrong or check controller wrong.

I try to read the guide in CI but im not find how to select database in there.

I hope there is place for checking my controller or database.

function clearagentdetails() {
        $('#txt_agent_name').val('');
		$('#txt_agent_phone').val('');
		$('#txt_agent_email').val('');
        $('#txtMainAgtID').val('');
	}

$("#btnGenCobrokedetails").click(function () {
        getagentdetails($('#txt_agent_nik').val(), $('#ddl_principal').val());
        return false;
    });
	
function getagentdetails($agent_nik, $principal) {

        clearagentdetails();
        $.ajax({
            type: "POST",
            data: {agent_nik: $agent_nik, principal: $principal},
            url: '<?php echo base_url() . 'index.php/secondary/get_agentdetails1'; ?>',
            dataType: "JSON",
            success: function (data) {
                if ($.trim(data.astatus) != 'Active') {
                    $('#txt_agent_name').attr("disabled", false);
                    $("#lblCobrokeMsg").text('The agent status is ' + data.astatus);
                    $("#divCobrokeWarning").show();
                } else {
                    $("#lblCobrokeMsg").text('The agent status is ' + data.astatus);
                    $("#divCobrokeWarning").show();
                    $('#txt_agent_name').val(data.actname);
                    $('#txt_agent_phone').val(data.phone);
                    $('#txt_agent_email').val(data.email);
                    $('#txtMainAgtID').val(data.agentid);
                    $('#ddl_listing').attr("disabled", true);
                }
            }
        });
    }
//Controller Function
function get_agentdetails1() {
        $agentic =  $this->db->escape($this->input->post('agent_nik'));
        $principal =  $this->db->escape($this->input->post('principal'));
        $rs         = $this->secondary_model->get_agentic_select1($agentic,$principal);
        if ($rs->num_rows() > 0)
        {
           $row = $rs->row(); 
           $agentid = $row->agentid;
           $agentic = $row->agentic;
           $propnexid = $row->propnexid;
           $actname= $row->actname;
           $astatus = $row->astatus;
           $phone = $row->Phone;
           $email = $row->PrtEmail;
        }
        echo json_encode(array(
            "agentid" => $agentid,
            "agentic" => $agentic,
            "propnexid" => $propnexid,
            "actname" => "hahah",
            "astatus"=> "active",//"$astatus,
            "phone"=> $phone,
            "email"=> $email));
    }
    
    
//Model Function
function get_agentic_select1($agentic,$principal) {
        $a = $this->load->database('db_001', TRUE);
        $rs=$this->db->query("EXEC v2_AgentDetails @pAgentIC= $agent_nik ");
        $this->db->close();
        return $rs;
    }
<label>Agent ID<span style="color: red; font-size: 18px; font-weight: bold;">*</span></label>
<input type="text" minlength="16" maxlength="16" id="txt_agent_nik" name="txt_agent_nik" class="form-control required">
<label>Principal<span style="color: red; font-size: 18px; font-weight: bold;">*</span></label>
<input type="text" id="txt_agent_nik" name="txt_agent_nik" class="form-control required">

<a href="#" id="btnGenCobrokedetails"><span class="icon-arrow-right-3">Check Agent</span></a>

2
  • don't post MySQL host & passwords on public Commented Jul 3, 2019 at 6:32
  • This Question Related to this enter link description here Commented Jul 3, 2019 at 9:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.