• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to minus number in DB

#1
PHP Code:
  function minus_set($id)
  {
    $this->db->trans_start();
    $this->db->set('total_set''total_set - 1');
    $this->db->set('price''price - 300.00');
    $this->db->where('user_id'$user_id);
    $this->db->update('users_detail'$data);
    $this->db->trans_complete();

    if ($this->db->trans_status() === TRUE)
    {
      return true;
    }
    else
    {
      return false;
    }
  
This is my model. I want subtract the total set and price. But, its not working.. how to fix it?
thanks
This is me. JK not me.
Reply

#2
(01-08-2017, 05:11 AM)falcon812311 Wrote:
PHP Code:
  function minus_set($id)
  {
    $this->db->trans_start();
    $this->db->set('total_set''total_set - 1');
    $this->db->set('price''price - 300.00');
    $this->db->where('user_id'$user_id);
    $this->db->update('users_detail'$data);
    $this->db->trans_complete();

    if ($this->db->trans_status() === TRUE)
    {
      return true;
    }
    else
    {
      return false;
    }
  
This is my model. I want subtract the total set and price. But, its not working.. how to fix it?
thanks
PHP Code:
    $this->db->set('total_set''total_set - 1',FALSE);
    $this->db->set('price''price - 300.00',FALSE); 
https://www.codeigniter.com/user_guide/d...ilder::set
Reply

#3
(01-08-2017, 10:18 PM)Paradinight Wrote:
(01-08-2017, 05:11 AM)falcon812311 Wrote:
PHP Code:
  function minus_set($id)
  {
    $this->db->trans_start();
    $this->db->set('total_set''total_set - 1');
    $this->db->set('price''price - 300.00');
    $this->db->where('user_id'$user_id);
    $this->db->update('users_detail'$data);
    $this->db->trans_complete();

    if ($this->db->trans_status() === TRUE)
    {
      return true;
    }
    else
    {
      return false;
    }
  
This is my model. I want subtract the total set and price. But, its not working.. how to fix it?
thanks
PHP Code:
    $this->db->set('total_set''total_set - 1',FALSE);
    $this->db->set('price''price - 300.00',FALSE); 
https://www.codeigniter.com/user_guide/d...ilder::set

Thanks!
This is me. JK not me.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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