zoukankan      html  css  js  c++  java
  • CI框架更新与删除

    $this->load->database();
            // $query=$this->db->get('t_repayments');
            // $result = $query->result();
            // var_dump($query);


            $data=array(
                // 'card_no'=>'3001',
                'this_date'=>"5-7",
                "this_money"=>'2431',
                'remark'=>'update第三个参数测试',
                'is_done'=>1
            );

            //replace() 参数中有主键,就替换掉原来的记录,没有主键就新增一条记录。
            //没有指定条件 就是新增一条记录
            //this->db->where 对于replace()函数无效
            // $this->db->replace('t_repayments',$data);


            //set()

            // $remark ="set函数测试";
            //string参数演示
               // $this->db->set('remark',$remark);

               //数组参数测试
               //不加where() 会修改所有的数据
               // $this->db->set($data);
               // $this->db->where('card_no','3001');
               // $this->db->update('t_repayments');


               //update() 测试
               // $this->db->where('card_no','3001');
               // $this->db->update('t_repayments',$data);

            //使用update()的第三个参数 设置where子句--字符串形式
            // $this->db->update('t_repayments',$data,'card_no=3001');
            // //同上-- 数组形式
            // $card_no = '3002';
            // $this->db->update('t_repayments',$data,  array('card_no'=>$card_no) );

            //update_batch() 根据提供的数组或list 批量修改
            // $data = array(
            //     array(
            //         'card_no'=>'3003',
            //         'this_date'=>'4-2',
            //         'this_money'=>'990'
            //     ),
            //     array(
            //         'card_no'=>'3002',
            //         'this_date'=>'4-5',
            //         'this_money'=>'991',
            //         'remark' => '批量修改测试'

            //     )

            // );

            // $this->db->update_batch('t_repayments',$data,'card_no');

            //删除测试
            $pk = "3001";
            // $this->db->delete('t_repayments',array('card_no'=>$pk));

            $this->db->where('card_no',$pk);
            $this->db->delete('t_repayments');

  • 相关阅读:
    JAVA学习前应该了解
    JAVA帝国的诞生
    常用的快捷方式
    MarkDown学习
    运动检测
    图像分割
    感知机
    线性判别函数
    距离
    概率密度估计笔记——非参数估计
  • 原文地址:https://www.cnblogs.com/Orangeorchard/p/8974082.html
Copyright © 2011-2022 走看看