• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL stored procedure passing parameters issue in Model function.

#1
Hi All,

While I am trying to pass parameters on MySQL stored procedure, it is passing empty values and getting the below error. But when pass the same value in a SELECT statement WHERE clause it is working. I have been trying to get resolve this issue for last few days but couldn't resolve. Could you please help me to resolve.

A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' ,null,null)' at line 1
call get_payment_details(25,null,, ,null,null)

Thank you,
Raja
Reply

#2
Can you show the code? What CI version?
Reply

#3
(01-25-2018, 02:58 PM)pbarney Wrote: Can you show the code? What CI version?
Hi,

Below is the sample code. When I try to display all the parameter using "echo" it is displaying but these are able to pass stored processor. Could you please suggest me to resolve this.

Thank you..

Ajax:
$.ajax({  
      url:base_url +"staff/update_single_staff",       
      dataType:"text",
       data:new FormData($('#form_add_staff')[0]),
      method:"POST",  
      contentType:false,  
      processData:false,
      success:function(data){
          console.log(data);
        }
      });
    }
Controller function:
$staff_id = $this->input->post("hdn_staff_id_unique");
        //echo $str;
        
        $college_staff_id=  $this->input->post("staff_id");
        $college_id= $this->session->userdata('college_id');
        $first_name= $this->input->post("txt_first_name");
        $last_name= $this->input->post("txt_last_name");
        $father_name= $this->input->post("txt_father_name");
        $mother_name= $this->input->post("txt_mother_name");
        $aadhar= $this->input->post("aadhar");
        $gender= $this->input->post("gender");
        $date_of_birth= date('Y-m-d', strtotime($this->input->post("txt_dob")));
        $qualification= $this->input->post("txt_qualification");
        $designation= $this->input->post("txt_designation");
        $date_of_join= date('Y-m-d', strtotime($this->input->post("txt_doj")));
        $contact= $this->input->post("txt_contact");
        $email= $this->input->post("txt_email");
        $salary= $this->input->post("txt_salary");
        $address1= $this->input->post("txt_addr1");
        $address2= $this->input->post("txt_addr2");
        $photo= $temp_image;
        $last_modified_date = date('Y-m-d H:iConfused');
        $this->load->model("staff_model");
        $result = $this->staff_model->update_single_staff($staff_id,$college_id,$college_staff_id,$first_name,$last_name,$father_name,$mother_name,$aadhar,$gender,$date_of_birth,$qualification,$designation,$date_of_join,$contact,$email,$salary,$address1,$address2,$photo,$last_modified_date);
        //echo "Staf_id: ".$this->input->post("hdn_staff_id_unique");
        echo json_encode($result);

Model:
function update_single_staff ($staff_id,$college_id,$college_staff_id,$first_name,$last_name,$father_name,$mother_name,$aadhar,$gender,$date_of_birth,$qualification,$designation,$date_of_join,$contact,$email,$salary,$address1,$address2,$photo,$last_modified_date){
        $this->db->reconnect();
        $query = $this->db->query("call update_single_staff(".$staff_id.",".$college_id.",".$college_staff_id.",`".$first_name."`,`".$last_name."`,'".$father_name."','".$mother_name."','".$aadhar."','".$gender."','".$date_of_birth."','".$qualification."','".$designation."','".$date_of_join."','".$contact."','".$email."',".$salary.",'".$address1."','".$address2."','".$photo."','".$last_modified_date."')");
        return $query->result_array();        
    }
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.