dongquanlin1885 2015-11-17 16:50
浏览 69
已采纳

在codeigniter中添加两个数组变量

I am building a system where i need to update the value in the database field but before doing that i need to take the current value in the database then adding it to the current value the following is a code from the controller.

public function transfer_amount(){



    $email  =  $this->input->post('view');

    $this->load->model('user_model');

    $data['user_balance'] = $this->user_model->fetch_balance($email);

    $data['balance'] = $this->input->post('amount');

    $data['total'] = $this->math->add($data['balance'],$data['user_balance']);


    $data = array(

            'balance' => $data['total'],

    );




    if($this->user_model->transfer_amount($data,$email)== true){


        $this->load->view('layer_service/success',$data);


    }
    else
    {


        $this->load->view('layer_service/unsuccessfull',$data);
    }



}

}

then the code in the module that fetch the current balance from the database is as following.

 function fetch_balance($email){


    $this->db->select('balance');
    $this->db->from('tbl_users');
    $this->db->where('email', $email);

    $query = $this->db->get();
    $result = $query->result();

    return $result;


}
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 有人知道怎么将vsi格式的图片文件,转换为svs格式的文件吗
      • ¥15 历史模拟法计算var实验报告
      • ¥15 白鲸算法优化K值的VMD分解出错
      • ¥20 写一个基于52单片机用hc-05蓝牙模块控制28BYJ-48步进电机进行旋转,在手机蓝牙串口输入1019电机转半圈,输入2038电机转一圈,输入0复位的代码吗
      • ¥15 求51单片机8位数码管计时器程序
      • ¥20 matlab识别螺母边缘
      • ¥15 python 6x6游戏加登录、记录系统
      • ¥100 基于做一个模拟智慧路灯
      • ¥15 ME21N 创建采购成功并且生成采购订单号,但显示“快件文档更新已取消”,SM13看错误提示为如下截图:
      • ¥30 android 集成fmod实现变声功能中遇到的问题