• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
best way to set concat in codeigniter?

#1
Hi,

I have problem with CONCAT function in mysql.

this is my code


PHP Code:
  function genitpsID()
  {

      $this->db->trans_start();
      $this->db->set(NULL);
      $this->db->insert('gen_dummy_id_itps');
      $itps_insert_id $this->db->insert_id();
      $this->db->trans_complete();

      $itps "ITPS";
      $myquery "CONCAT('$itps','LPAD('$itps_insert_id', 3, '0'))";
      if ($this->db->trans_status() === TRUE)
      {
        $this->db->set('itps_id',$myquery);
        $this->db->insert('test_gen_id');
      }
      else
      {
        return false;
      }
  


I can't set concat in codeigniter.. the output is will like this 
PHP Code:
CONCAT('ITPS','LPAD('6', 3, '0'))  

My reference.. 
http://stackoverflow.com/questions/17893...ome-prefix
Please help me.. Sad
This is me. JK not me.
Reply

#2
try 
$myquery = "CONCAT($itps, LPAD($itps_insert_id, 3, 0))";
or
$myquery = "CONCAT('" . $itps . "', LPAD('" . $itps_insert_id . "', 3, 0))";
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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