鑫安财富项目随记6--如何进行多项删除

这几天浑浑噩噩的,就没写博了,今天花了一早上搞了下多项删除功能,下面是一点心得

首先是页面的

<a href="javascript:void(0)" onclick="delModel({form:'expertListForm',msg:'确定要删除所选中的业务员吗?<br />删除的业务员无法找回!!'})"><button class="operating_btn" type="button"><span class="delete">批量删除</span></button></a>
<form name="expertListForm" action="{url:/member/expert_dell}" method="post" >


然后是php

function expert_dell(){
    //post数据
    $id = IFilter::act(IReq::get('id'),'int');
    $id_str = $id;
    //生成professional对象
$tb_pro = new IModel('professional'); if(!empty($id)) { $where = ''; $id_str = join(',',$id); $where = ' id in ('.$id_str.')'; //删除订单 $tb_pro->del($where); $this->redirect('expert_list'); } else { $this->redirect('expert_list',false); Util::showMessage('请选择要删除的数据'); } }

这个php写的就有点丑陋了。。。。。
学长说删除单条和删除多条可以写进一个函数中

if(is_array($id) && isset($id[0]) && $id[0]!='')
            {
                $id_str = join(',',$id);
                $where1 = ' id in ('.$id_str.')';
                $where2 = ' article_id in ('.$id_str.')';
            }
            else
            {
                $where1 = 'id = '.$id;
                $where2 = 'article_id = '.$id;
            }

这个看起来就舒服多了。

抢饭去咯~

 

 

转载于:https://www.cnblogs.com/sjnloveprogram/archive/2012/07/08/2581292.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值