当前位置: 首页>>代码示例>>PHP>>正文


PHP SwatDB::implodeSelection方法代码示例

本文整理汇总了PHP中SwatDB::implodeSelection方法的典型用法代码示例。如果您正苦于以下问题:PHP SwatDB::implodeSelection方法的具体用法?PHP SwatDB::implodeSelection怎么用?PHP SwatDB::implodeSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SwatDB的用法示例。


在下文中一共展示了SwatDB::implodeSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processActions

    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
开发者ID:nburka,项目名称:blorg,代码行数:33,代码来源:Index.php

示例2: publishPosts

    protected function publishPosts(SwatViewSelection $post_ids)
    {
        $num = 0;
        $transaction = new SwatDBTransaction($this->app->db);
        try {
            $instance_id = $this->app->getInstanceId();
            $post_ids = SwatDB::implodeSelection($this->app->db, $post_ids);
            $sql = sprintf('select id, shortname, title, bodytext from BlorgPost
				where instance %s %s and id in (%s) and enabled = %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $post_ids, $this->app->db->quote(false, 'boolean'));
            $posts = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgPostWrapper'));
            foreach ($posts as $post) {
                if ($post->shortname === null) {
                    $post->shortname = $this->getPostShortname($post);
                }
                $post->enabled = true;
                $post->save();
                $num++;
            }
            $transaction->commit();
        } catch (Exception $e) {
            $transaction->rollback();
            throw $e;
        }
        if ($num > 0 && isset($this->app->memcache)) {
            $this->app->memcache->flushNs('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been shown on site.', '%s posts have been shown on site.', $num), SwatString::numberFormat($num)));
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:28,代码来源:Index.php

示例3: processActions

    /**
     * Processes photographer actions
     *
     * @param SwatTableView $view the table-view to get selected tags
     *                             from.
     * @param SwatActions $actions the actions list widget.
     */
    protected function processActions(SwatTableView $view, SwatActions $actions)
    {
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->checked_items, $view->getColumn('checkbox')->isExtendedCheckAllSelected());
                break;
            case 'archive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been archived.', '%s tags have been archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unarchive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not archived.', '%s tags have been set as not archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'event':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as an event.', '%s tags have been set as events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unevent':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not an event.', '%s tags have been set as not events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
        }
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:48,代码来源:Index.php


注:本文中的SwatDB::implodeSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。