CodeIgniter Forums

Full Version: best way to set concat in codeigniter?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
try 
$myquery = "CONCAT($itps, LPAD($itps_insert_id, 3, 0))";
or
$myquery = "CONCAT('" . $itps . "', LPAD('" . $itps_insert_id . "', 3, 0))";