Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Query
#1

i have problem to saving data

this is my Model
i use Sql Server Database

  function UpdateEdit($data)
  {

     $this->db->trans_start();
     $sql = " update [do] set customer='" . $data['Customer'] . "', tgl='" . $data['Tgl'] . "', Notes='" . $data['Notes'] . "', Total=" . $data['Total']
          . " where doid='" . $data['Doid'] . "'";    
     print_r($sql);

      $head =  $this->db->query($sql);

     $this->db->delete("from DoDtl where Doid='" . $Doid . "'");

     $this->db->query($data['Detail']);
     $this->db->trans_complete();

     return TRUE;
  }
Reply
#2

(This post was last modified: 04-06-2019, 12:37 PM by php_rocs.)

@amansusanto,

What errors are you seeing? Also, I wouldn't do you query like that.  You could open yourself up to sql injections.  I would use this the query binding method instead (https://www.codeigniter.com/userguide3/d...y-bindings ).

PHP Code:
      $sql " update [do] set customer=?, tgl=?, Notes=?, Total=? where doid=?"  

      $head 
 $this->db->query($sql,[$data['Customer'],$data['Tgl'],$data['Notes'],$data['Total'],$data['Doid']]);
 
     print_r($this->db->last_query()); 
Reply
#3

(04-06-2019, 12:23 PM)php_rocs Wrote: @amansusanto,

What errors are you seeing? Also, I wouldn't do you query like that.  You could open yourself up to sql injections.  I would use this the query binding method instead (https://www.codeigniter.com/userguide3/d...y-bindings ).

PHP Code:
      $sql " update [do] set customer=?, tgl=?, Notes=?, Total=? where doid=?"  

      $head 
 $this->db->query($sql,[$data['Customer'],$data['Tgl'],$data['Notes'],$data['Total'],$data['Doid']]);
 
     print_r($this->db->last_query()); 

i have wrong type table column name. now already solved..
Thank you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB