Welcome Guest, Not a member yet? Register   Sign In
How to minus number in DB
#1

(This post was last modified: 01-08-2017, 09:39 AM by falcon812311. Edit Reason: change minus to subtraction, to easy understand )

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




Theme © iAndrew 2016 - Forum software by © MyBB