简体   繁体   中英

How to update value of particular column in database in codeigniter

Currently i am working on ecommerece website in that on vendor side whenever user generate order that amount of order should add to wallet (Ex.If amount in vendor wallet is 1500 and user has generated order of 500 than the updated value of wallet should be 2000)But in my case it is becoming 500 . if any body know solution than please help.Below is my code for controller.php

Public function clone_job()
    {
        $sellerData = $this->Mdl_admin_login->seller_list();
        foreach ($sellerData as $seller)
        {
            $wallet = 0;
            $payment = $this->Mdl_admin_login->get_payment_list($seller['id']);
            foreach ($payment as $payments){
                $wallet =  $wallet + $payments['settlement_price']*$payments['qty'];
                $wallets = $this->Mdl_admin_login->add_wallet($wallet,$seller['id']);
                $is_pay = $this->Mdl_admin_login->is_pay($payments['id']);
            }
        }
    }

model.php

function add_wallet($wallet,$id)
    {
        $data = array(
            'wallet' => $wallet,
        );
        $this->db->where('id',$id);
        $this->db->update('seller', $data);
    }

You can use like

function add_wallet($wallet,$id){
    $this->db->set('wallet', 'wallet+'. $wallet, false);
    $this->db->where('id',$id);
    $this->db->update('seller');
}

Please try this.

function add_wallet($wallet,$id){
    $this->db->set('wallet', 'wallet+'. $wallet, false);
    $this->db->where('id',$id);
    $this->db->update('seller');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM