2016-08-01 5 views
1

Ich bin nicht in der Lage, mehrere Spalten derselben Zeile mit der Zeile zu aktualisieren, die mit der Benutzer-ID im Codezeichen übereinstimmt.Codeigniter: Mehrere Spalten derselben Zeile Aktualisierungsabfrage funktioniert nicht

Mein Controller-Code ist:

exits.php

\t function update_act_on_resignation(){ 
 
\t \t \t \t global $SITE,$USER; 
 
\t \t \t $data = array(); 
 
\t \t \t $data['row'] = new stdClass(); 
 
\t \t \t $data['row'] = $this->admin_init_elements->set_post_vals($this->input->post()); 
 
\t \t \t $data['offices']=$this->mod_common->get_all_offices(); 
 
\t \t \t $clients = currentuserclients(); 
 
\t \t \t $data['roles'] = $this->mod_common->get_cat_array('designation','status',"1' AND id > '0",'designation'); 
 
\t \t \t get_city_state_country_array($data,array('cityid'=>$data['row']->cityid)); 
 
\t \t \t $data['error_message'] = ''; 
 
\t \t \t $data['row']->id = $this->uri->segment(3); 
 
\t \t \t $data['id'] = $this->uri->segment(3); 
 
\t \t \t $data['action'] = 'add'; 
 
\t \t \t $data['heading'] = 'Add'; 
 
\t \t \t $data['msg_class'] = 'sukses'; 
 
\t \t \t $data['path']=$path; 
 
\t \t \t $post_action = $this->input->post('action'); 
 
\t \t \t if($post_action=='add' || $post_action =='update'){ 
 
\t \t \t \t $post_array = $this->input->post(); 
 
\t \t \t \t $action = ($post_action == 'add')?'inserted':'updated'; 
 
\t \t \t \t //echo '<pre>';print_r($SITE);die; 
 
\t \t \t \t echo $post_array['exit_type'] = 'Employee Initiated'; 
 
\t \t \t \t \t \t \t \t echo $post_array[$id] = $USER->id; 
 
      echo $post_array['custom-105965']; 
 
      echo $post_array['manager_comments']; 
 
      echo $post_array['accept']; 
 
\t   echo $post_array['agreed_last_date']; 
 
\t \t \t 
 

 
\t \t \t \t \t $data['success_message'] = $this->exit_common->update_get_resignation_to_act($post_array,$action); 
 

 

 
\t \t \t \t \t if($data['success_message'] == 'Record '.$action.' successfully'){ 
 
\t \t \t \t \t \t $data['row'] = new stdClass(); 
 
\t \t \t \t \t \t $data['row']->id = $this->uri->segment(3); 
 
\t \t \t \t \t \t $data['row']->status = 1; 
 

 
\t \t \t \t \t } 
 

 
\t \t \t } 
 
\t \t \t 
 
\t \t \t $this->data['maincontent'] = $this->load->view('maincontents/view_resignation_action', $data,true); 
 
\t \t \t echo "Resignation withdrawn successfully!"; 
 
\t \t \t 
 
\t \t \t $this->load->view('layout', $this->data); 
 
\t \t }

Ich hallte die Ergebnisse einer Form bekam zu überprüfen, ob ich die gesendeten Elemente Form erhalte und i habe alles richtig erhalten. dh ich bekomme 67 für $ post_array [$ id] Ja für $ post_array ['custom-105965'] asd für $ post_array ['manager_comments'] Akzeptiere für $ post_array ['accept'] und 01-01-1970 als $ post_array ['vereinbart_letzter_Datum'] nach dem Echo.

My Model-Code ist:

exit_common.php

\t function update_get_resignation_to_act($post_array,$action){ 
 
\t \t \t 
 
\t $this->load->database(); 
 
    $this->db->where('userids', $post_array['id']); 
 
    $dbdata['discussion'] = $post_array['custom-105965']; 
 
    $dbdata['manager_comments'] = $post_array['manager_comments']; 
 
    $dbdata['last_status'] = $post_array['accept']; 
 
\t $dbdata['agreed_date'] = $post_array['agreed_last_date']; 
 
\t 
 
    $this->db->update('pr_resignation_requests', $dbdata); 
 
\t \t \t \t return; 
 
\t \t \t \t \t \t 
 
\t \t \t 
 
\t \t \t 
 
\t \t }

Ich denke, etwas mit der Modell-Update-Funktion falsch ist. Aber nicht in der Lage, herauszufinden, was falsch ist, da eine ähnliche Funktion für die Aktualisierung einer einzelnen Spalte in db arbeitet. Fehle ich etwas? Es ist eine MySQL-Datenbank.

Mein Code anzeigen ist:

view_resignation_action.php

<style> 
 
label{font-weight:bold;} 
 

 
.hbox .col { 
 
    display: table-cell; 
 
    float: none; 
 
    height: 100%; 
 
    vertical-align: top; 
 
\t width:100%; 
 
} 
 
</style> 
 
<div class="new"> 
 
    <section class="content-header"> 
 
      <h1> 
 
\t \t \t Resignation Action 
 
      </h1> 
 
      <ol class="breadcrumb" > 
 
      <li><a href="<?php base_url(); ?>"><i class="fa fa-home"></i> Home</a></li> 
 
      <li><a href="#">People Connect</a></li> 
 
\t \t \t <li><a href="<?php echo base_url(); ?>exits">Exit Tracker</a></li> 
 
\t \t \t <li class="active">Exit Details</li> 
 
      
 
      </ol> 
 
    </section> 
 
\t <input type="hidden" id="page_name" value="requests"> \t 
 
\t 
 
<div class="container-fluid"> 
 
        <div class="row"> 
 
         <!-- Thought Day--> 
 
         <div class="panel wrapper clearfix m-b-none"> 
 
       <!-- Horizontal Form --> 
 
       
 
       <div class="box-header with-border"> 
 
        
 
       </div><!-- /.box-header --> 
 
       <!-- form start --> 
 
\t \t \t \t \t <?php if($error_message!=''){?> 
 
\t \t \t \t \t \t \t \t <div class="row-fluid return-message success-message <?php echo $msg_class; ?>"><?php echo $error_message;?></div> 
 
\t \t \t \t \t \t \t <?php } else { ?> 
 
       <?php echo form_open('exits/update_act_on_resignation/',array('name'=>'addostcstevent','id'=>'addostcstevent','method'=>'post','autocomplete'=>'on','class'=>'form-horizontal'))?> 
 
\t \t \t \t \t <?php echo form_hidden(array('id'=>$USER->id,'action'=>$action));?> 
 
\t \t \t \t \t 
 
\t \t \t \t \t <?php foreach($rows as $row){ ?> 
 
        <div class="panel-body"> 
 
\t \t \t \t \t <div class="control-group form-group"> 
 
\t \t \t \t \t \t <div class="col-md-6"> 
 
\t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t \t \t <div class="col-md-5"> 
 
\t \t \t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t \t \t \t <label class="control-label" style="text-align:left">Name of the employee </label> 
 
\t \t \t \t \t \t \t \t \t \t <div class="controls"><?php echo $row->firstname; ?> 
 
\t \t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t \t <div class="col-md-5"> 
 
\t \t \t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t <div class="col-md-6 pull-right"> 
 
\t \t \t \t \t \t \t <label class="control-label" style="text-align:left">Date of request </label><div class="controls"> 
 
\t \t \t \t \t \t \t \t \t \t <?php echo $row->resignations_date; ?> 
 
\t \t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t </div> \t 
 
\t \t \t \t \t <div class="clearfix"></div> \t \t \t \t \t 
 
\t \t \t \t \t <div class="control-group form-group"> 
 
\t \t \t \t \t \t <div class="col-md-6 "> 
 
\t \t \t \t \t \t \t <label class="control-label" style="text-align:left">Requested Last Working Date</label> 
 
\t \t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-10"> 
 
\t \t \t \t \t \t \t \t \t <?php echo $row->requested_date; ?> 
 
\t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t 
 
\t \t \t \t \t \t <div class="col-md-6 pull-right"> 
 
\t \t \t \t \t \t \t <label class="control-label">Reason</label> 
 
\t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-9"> 
 
\t \t \t \t \t \t \t <?php echo $row->exit_type; ?> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t 
 
\t \t \t \t \t \t \t \t <div class="col-md-6 pull-right"> 
 
\t \t \t \t \t \t \t <label class="control-label">Comments from Employee</label> 
 
\t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-9"> 
 
\t \t \t \t \t \t \t <?php echo $row->comments; ?> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t <br><br><br><br><br><br><br> 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t <fieldset id="f1" class="col-md-6 pull-left"> <!-- start fieldset --> 
 
\t \t \t \t \t 
 

 
\t \t \t \t \t <div class="label"> 
 
\t \t \t \t \t 
 

 

 
    </label> 
 
</div> 
 
<div class="input"> 
 

 
</div> 
 
</div> 
 
</td> 
 
</table> 
 
</td> 
 
</tr> 
 
<tr> 
 
    <td> 
 
     <table width="100%" style="text-align:left"> 
 
\t \t 
 
\t \t \t \t \t <label class="control-label" style="text-align:left">Have you had a discussion with Employee?</label> 
 
\t \t \t \t \t \t <table> 
 
\t \t \t \t \t \t \t <td valign="top"> 
 
\t \t \t \t \t \t \t <input id="custom-105965_0" class="custom-105965" name="custom-105965" value="Yes" type="radio"> 
 
\t \t \t \t \t \t \t <label for="custom-105965_0">Yes 
 
\t \t \t \t \t \t \t <br> 
 
\t \t \t \t \t \t \t </label> 
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t <td valign="top"> 
 
\t \t \t \t \t \t \t <input id="custom-105965_1" class="custom-105965" name="custom-105965" value="No" type="radio"> 
 
\t \t \t \t \t \t \t <label for="custom-105965_1">No 
 
     
 
\t \t \t \t \t </label> 
 
\t \t \t \t </td> 
 
\t \t </table> 
 
      <td valign="top"> 
 
       <div class="fieldset" id="bsd-field-custom-105967-group"> 
 
\t \t \t \t \t \t <div class="col-md-6 pull-left"> 
 
\t \t \t \t \t \t \t <label class="control-label">Please enter your comments</label> 
 
\t \t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-12"> 
 
\t \t \t \t \t \t \t <textarea required class="form-control" name="manager_comments"></textarea> 
 
\t \t \t \t \t \t \t \t <!--<input placeholder="Please enter your comments" class="" id="dateofrequest" type="text" name="todays_date" value=""/> \t <br><br>--> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t <label class="control-label">Action</label> 
 
\t \t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-9"> 
 
\t \t \t \t \t \t \t <?php $dd_list = array(
 
\t \t \t \t \t \t \t \t 'Accept' => 'Accepted', 
 
\t \t \t \t \t \t \t \t 'Reject' => 'Rejected', 
 
\t \t \t \t \t \t \t \t); 
 
\t \t \t \t \t \t \t echo form_dropdown('accept', $dd_list, 'Accept'); 
 
\t \t \t \t \t \t \t ?> \t 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t \t <label class="control-label">Agreed Last Working day</label> 
 
\t \t \t \t \t \t \t <div class="controls"> 
 
\t \t \t \t \t \t \t <div class="col-md-9"> 
 
\t \t \t \t \t \t \t \t <input placeholder="Agreed Last Working day" class=" m-wrap col-md-8 form-control " id="startdt" type="text" name="agreed_last_date" value="<?php if($row->requested_date!='') echo date("d-m-Y",$row->requested_date); ?>" required/> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t <br><br> 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t \t <div class="col-md-9"> 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t 
 
\t \t 
 
\t \t \t \t \t 
 
       </div> 
 
\t \t \t \t <!-- If its a no --> 
 
\t \t \t \t   <div class="fieldset" id="bsd-field-custom-105867-group"> 
 
\t \t \t \t \t \t <div class="col-md-6 pull-left"> 
 
\t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t \t <div class="alert alert-success alert-dismissable"> 
 
      <label type="button"></label> 
 
      Please have a discussion with the employee. 
 
     </div> 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t 
 
\t \t 
 
\t \t \t \t \t 
 
       </div> 
 
      </td> 
 
     </table> 
 
    </td> 
 
</tr> 
 

 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t </fieldset><!-- End Fiedset --> 
 
\t \t \t \t \t 
 
\t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t \t <?php }?> 
 
\t \t \t \t <div class="clearfix"></div> 
 
\t \t \t \t <div class=" box-footer"> 
 
\t \t \t \t \t <button type="submit" class="btn btn-info pull-right" style="margin:0px 10px">submit</button> 
 
\t \t \t \t \t 
 
\t \t \t \t </div> 
 
\t \t \t \t </form> 
 
\t \t \t \t \t \t \t <?php } ?> 
 
\t \t \t \t <div class="clearfix"></div> 
 
\t \t \t </div> 
 
\t \t </div> 
 
\t \t </div> 
 
\t </section> 
 
\t </div> 
 
\t <script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script> 
 
\t <script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/select2/select2.min.js"></script> 
 
\t <script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> 
 
\t <script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"></script> 
 

 
<script> 
 
$(".fieldset").hide(); 
 
\t \t $(document).ready(function() { 
 
    $("[id^=bsd-field-custom-1059]").hide(); 
 
    $(".custom-105965").change(function() { 
 
     $("[id^=bsd-field-custom-1059]").toggle(this.value == 'Yes'); 
 
    }); 
 
\t 
 
}); 
 
$(document).ready(function() { 
 
    $("[id^=bsd-field-custom-1059]").hide(); 
 
    $(".custom-105965").change(function() { 
 
     $("[id^=bsd-field-custom-1058]").toggle(this.value == 'No'); 
 
\t \t  $('.alert').show() 
 
    }); 
 
\t 
 
}); 
 
$(document).ready(function(){ 
 
\t \t $("#startdt").datepicker({ 
 
\t \t \t dateFormat: 'dd-mm-yy', 
 
\t \t \t changeMonth: true, 
 
\t \t \t changeYear: true, 
 
\t \t \t showButtonPanel: true, 
 
\t \t \t yearRange: "-90:+0", 
 
\t \t \t endDate: new Date(), 
 
\t \t \t autoclose: true 
 
\t \t }).on('changeDate', function (selected) { 
 
\t \t \t var minDate = new Date(selected.date.valueOf()); 
 
\t \t \t $('#enddt').datepicker('setStartDate', minDate); 
 
\t \t }); 
 
\t \t $("#enddt").datepicker({ 
 
\t \t \t dateFormat: 'dd-mm-yy', 
 
\t \t \t changeMonth: true, 
 
\t \t \t changeYear: true, 
 
\t \t \t showButtonPanel: true, 
 
\t \t \t yearRange: "-90:+0", 
 
\t \t \t endDate: new Date() 
 
\t \t }); 
 
\t \t $(".date-picker").datepicker(); 
 
\t \t $('.timepicker-default').timepicker(); 
 
\t \t $('#report_date').datepicker({ 
 
\t \t \t format: "mm-yyyy", 
 
\t \t \t viewMode: "months", 
 
\t \t \t minViewMode: "months" 
 
\t \t }); 
 
\t \t 
 
\t \t \t $(".select2").select2({ 
 
\t \t \t \t placeholder: "Select an option", 
 
\t \t \t \t allowClear: true 
 
\t \t \t }); 
 
\t \t \t \t $("#asset_type").change(function(){ 
 
\t \t \t \t \t if($(this).val() == '-1') { 
 
\t \t \t \t \t \t $("#new_type").show(); 
 
\t \t \t \t \t } 
 
\t \t \t \t \t else 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t $("#new_type").hide(); 
 
\t \t \t \t \t } 
 
\t \t \t \t }); 
 

 
\t \t \t \t $("#manufacturer").change(function(){ 
 
\t \t \t \t \t if($(this).val() == '-1') { 
 
\t \t \t \t \t \t $("#new_manufacturer").show(); 
 
\t \t \t \t \t } 
 
\t \t \t \t \t else 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t $("#new_manufacturer").hide(); 
 
\t \t \t \t \t } 
 
\t \t \t \t }); 
 

 
\t \t \t \t $("#supplier").change(function(){ 
 
\t \t \t \t \t if($(this).val() == '-1') { 
 
\t \t \t \t \t \t $("#new_supplier").show(); 
 
\t \t \t \t \t } 
 
\t \t \t \t \t else 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t $("#new_supplier").hide(); 
 
\t \t \t \t \t } 
 
\t \t \t \t }); 
 
\t \t }); 
 
\t \t 
 

 
\t \t 
 
</script>

Mysql Tabelle ist: enter image description here

Antwort

2

Unten Snippet Versuchen

function update_get_resignation_to_act($post_array,$action) 
{  
    $this->load->database(); 
    $this->db->where('userids', $post_array['id']); 
    $dbdata = array(
      "discussion" => $post_array['custom-105965'], 
      "manager_comments" => $post_array['manager_comments'], 
      "last_status" => $post_array['accept'], 
      "agreed_date" => $post_array['agreed_last_date'] 
    ); 
    $this->db->update('pr_resignation_requests', $dbdata); 
    /** 
    * if required add this code here to check 
    * 
    * echo $this->db->last_query(); 
    */ 
    return;  
} 
+0

echo abfragen und in phpmyadmin ausführen. –

+0

Wird nicht in der Datenbank aktualisiert – shank

+0

können Sie eine Abfrage abfragen? und einfügen auf Kommentar –

Verwandte Themen