Home >php教程 >php手册 >php下拉选项的批量操作的实现代码

php下拉选项的批量操作的实现代码

WBOY
WBOYOriginal
2016-06-06 20:27:21916browse

这篇文章介绍了php下拉选项的批量操作的实现代码,有需要的朋友可以参考一下

php下拉选项的批量操作的实现代码

实现功能,操作项可以单独删除,批量项可以批量删除,,批量显示,隐藏(改广告的数据库的status_is的值);

1.视图关键点:

复制代码 代码如下:



        id?>

复制代码 代码如下:



         
         
         
         
       

复制代码 代码如下:


/*单个删除*/

2.控制器:

复制代码 代码如下:


/**
     * 批量操作
     *
     */
    public function actionBatch ()
    {
        if (XUtils::method() == 'GET') {     //单个删除是get方式
            $command = trim($_GET['command']);
            $ids = intval($_GET['id']);
        } else
            if (XUtils::method() == 'POST') {
                $command = trim($_POST['command']);
                $ids = $_POST['id'];
                is_array($ids) && $ids = implode(',', $ids);
            } else {
                XUtils::message('errorBack', '只支持POST,GET数据');
            }
        empty($ids) && XUtils::message('error', '未选择记录');

        switch ($command) {

            case 'adDelete':
                parent::_acl('ad_delete');
                parent::_adminiLogger(array('catalog'=>'delete', 'intro'=>'删除广告,ID:'.$ids));
                parent::_delete(new Ad(), $ids, array ('ad' ), array ('attach_file' ));
                break;
            case 'adVerify':
                parent::_acl('ad_verify');
                parent::_adminiLogger(array('catalog'=>'delete', 'intro'=>'广告状态变更为显示,ID:'.$ids));
                parent::_verify(new Ad(), 'verify', $ids, array ('ad' ));

                break;
            case 'adUnVerify':
                parent::_acl('ad_verify');
                parent::_adminiLogger(array('catalog'=>'delete', 'intro'=>'广告状态变更为隐藏,ID:'.$ids));
                parent::_verify(new Ad(), 'unVerify', $ids, array ('ad' ));
                break;
            default:
                throw new CHttpException(404, '错误的操作类型:' . $command);
                break;
        }

    }

父类的删除函数:

复制代码 代码如下:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn