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


PHP SwatDB::exec方法代码示例

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


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

示例1: processDBData

    protected function processDBData()
    {
        parent::processDBData();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        // delete attached files using their dataobjects to remove the actual
        // files
        $sql = sprintf('select * from BlorgFile
			inner join BlorgPost on BlorgPost.id = BlorgFile.post
			where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper'));
        foreach ($files as $file) {
            $file->setFileBase('../');
            $file->delete();
        }
        // delete the posts
        $sql = sprintf('delete from BlorgPost
			where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $num = SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNS('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
开发者ID:nburka,项目名称:blorg,代码行数:25,代码来源:Delete.php

示例2: 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

示例3: finalize

 public function finalize()
 {
     $base_sql = 'update Article set parent = %s where id = %s';
     foreach ($this->table->parents as $id => $parent) {
         $sql = sprintf($base_sql, $this->table->process->dst_db->quote($parent, 'integer'), $this->table->process->dst_db->quote($id, 'integer'));
         SwatDB::exec($this->table->process->dst_db, $sql);
     }
 }
开发者ID:nburka,项目名称:blorgy,代码行数:8,代码来源:ArticleTable.php

示例4: addToSearchQueue

    protected function addToSearchQueue(PinholePhoto $photo)
    {
        $type = NateGoSearch::getDocumentType($this->app->db, 'photo');
        $sql = sprintf('delete from NateGoSearchQueue
			where document_id = %s and document_type = %s', $this->app->db->quote($photo->id, 'integer'), $this->app->db->quote($type, 'integer'));
        SwatDB::exec($this->app->db, $sql);
        $sql = sprintf('insert into NateGoSearchQueue
			(document_id, document_type) values (%s, %s)', $this->app->db->quote($photo->id, 'integer'), $this->app->db->quote($type, 'integer'));
        SwatDB::exec($this->app->db, $sql);
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:10,代码来源:PinholePhotoProcessor.php

示例5: detach

    /**
     * Marks a file as not attached
     *
     * @param integer $file_id the id of the file to mark as not attached.
     *
     * @return boolean true.
     */
    public function detach($file_id)
    {
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('update BlorgFile set visible = %s
			where instance %s %s and id = %s', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->quote($file_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        if ($num > 0 && isset($this->app->memcache)) {
            $this->app->memcache->flushNS('posts');
        }
        return true;
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:18,代码来源:FileAjaxServer.php

示例6: saveIndex

    protected function saveIndex($id, $index)
    {
        SwatDB::updateColumn($this->app->db, 'BlorgAuthor', 'integer:displayorder', $index, 'integer:id', array($id));
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('update BlorgAuthor set displayorder = %s
			where id = %s and instance %s %s', $this->app->db->quote($index, 'integer'), $this->app->db->quote($id, 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNs('authors');
        }
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:11,代码来源:Order.php

示例7: processDBData

 protected function processDBData()
 {
     parent::processDBData();
     $sql = 'delete from CMEFrontMatter where id in (%s);';
     $item_list = $this->getItemList('integer');
     $sql = sprintf($sql, $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     $locale = SwatI18NLocale::get();
     $message = new SwatMessage(sprintf(CME::ngettext('One CME front matter has been deleted.', '%s CME front matters have been deleted.', $num), $locale->formatNumber($num)));
     $this->app->messages->add($message);
 }
开发者ID:nrfredrickson,项目名称:Cme,代码行数:11,代码来源:Delete.php

示例8: processDBData

 protected function processDBData()
 {
     parent::processDBData();
     $sql = 'delete from Block where id in (%s)';
     $item_list = $this->getItemList('integer');
     $sql = sprintf($sql, $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     if ($num > 0) {
         $this->app->messages->add(new SwatMessage(Building::_('Content has been deleted.')));
     }
 }
开发者ID:GervaisdeM,项目名称:Building,代码行数:11,代码来源:Delete.php

示例9: processDBData

    protected function processDBData()
    {
        parent::processDBData();
        $instance_id = $this->app->getInstanceId();
        $sql = 'delete from PinholePhotographer where id in (%s)
			and instance %s %s';
        $item_list = $this->getItemList('integer');
        $sql = sprintf($sql, $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        $message = new SwatMessage(sprintf(Pinhole::ngettext('One photographer has been deleted.', '%s photographers have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:12,代码来源:Delete.php

示例10: addToSearchQueue

    protected function addToSearchQueue()
    {
        $type = NateGoSearch::getDocumentType($this->app->db, 'comment');
        if ($type === null) {
            return;
        }
        $sql = sprintf('delete from NateGoSearchQueue
			where document_id = %s and document_type = %s', $this->app->db->quote($this->comment->id, 'integer'), $this->app->db->quote($type, 'integer'));
        SwatDB::exec($this->app->db, $sql);
        $sql = sprintf('insert into NateGoSearchQueue
			(document_id, document_type) values (%s, %s)', $this->app->db->quote($this->comment->id, 'integer'), $this->app->db->quote($type, 'integer'));
        SwatDB::exec($this->app->db, $sql);
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:13,代码来源:PinholeCommentUi.php

示例11: processDBData

 protected function processDBData()
 {
     parent::processDBData();
     $item_list = $this->getItemList('integer');
     $sql = sprintf('delete from BlorgTag where id in (%s)', $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('tags');
         $this->app->memcache->flushNs('posts');
     }
     $message = new SwatMessage(sprintf(Blorg::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:13,代码来源:Delete.php

示例12: processDBData

    protected function processDBData()
    {
        AdminDBDelete::processDBData();
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select parent from Article
			where id = %s and instance %s %s', $this->app->db->quote($this->getFirstItem(), 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $this->parent_id = SwatDB::queryOne($this->app->db, $sql);
        $item_list = $this->getItemList('integer');
        $sql = sprintf('delete from Article
			where id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        $message = new SwatMessage(sprintf(Site::ngettext('One article has been deleted.', '%s articles have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
开发者ID:nburka,项目名称:blorgy,代码行数:14,代码来源:Delete.php

示例13: processActions

    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $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':
                $this->publishPosts($view->getSelection());
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgPost set enabled = %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('posts');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been hidden on site.', '%s posts have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'tags_action':
                $tag_array = $this->ui->getWidget('tags')->getSelectedTagArray();
                if (count($tag_array) > 0) {
                    $posts = $this->getPostsFromSelection($view->getSelection());
                    foreach ($posts as $post) {
                        $post->addTagsByShortname($tag_array);
                    }
                    if (isset($this->app->memcache)) {
                        $this->app->memcache->flushNs('posts');
                        $this->app->memcache->flushNs('tags');
                    }
                    $num = count($view->getSelection());
                    $num_tags = count($tag_array);
                    if ($num_tags === 1) {
                        $tag = reset($tag_array);
                        $message = new SwatMessage(sprintf(Blorg::ngettext('The tag “%s” has been added to one post.', 'The tag “%s” has been added to %s posts.', $num), SwatString::minimizeEntities($tag), SwatString::numberFormat($num)));
                    } else {
                        $message = new SwatMessage(sprintf(Blorg::ngettext('%s tags have been added to one post.', '%s tags have been added to %s posts.', $num), SwatString::numberFormat($num_tags), SwatString::numberFormat($num)));
                    }
                    // clear selected tags
                    $this->ui->getWidget('tags')->setSelectedTagArray(array());
                }
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:49,代码来源:Index.php

示例14: setPhotoGpsData

    /**
     * Update a photo
     *
     * @param array $photo_ids The photo its to update
     * @param float $latitude Latitude
     * @param float $longitude Longitude
     * @param integer $zoom_level Zoom level for storing as a preference
     *
     * @return array The photo ids that were updated.
     */
    public function setPhotoGpsData(array $photo_ids, $latitude, $longitude, $zoom_level)
    {
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('update PinholePhoto set
			gps_latitude = %s, gps_longitude = %s
			where PinholePhoto.id in (select PinholePhoto.id from PinholePhoto
				inner join ImageSet on ImageSet.id = PinholePhoto.image_set
				where ImageSet.instance %s %s and PinholePhoto.id in (%s))', $this->app->db->quote($latitude, 'float'), $this->app->db->quote($longitude, 'float'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->implodeArray($photo_ids, 'integer'));
        SwatDB::exec($this->app->db, $sql);
        // save preferences
        $this->app->config->pinhole->map_last_latitude = $latitude;
        $this->app->config->pinhole->map_last_longitude = $longitude;
        $this->app->config->pinhole->map_last_zoom_level = $zoom_level;
        $this->app->config->save(array('pinhole.map_last_latitude', 'pinhole.map_last_longitude', 'pinhole.map_last_zoom_level'));
        // clear cache
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNs('photos');
        }
        return $photo_ids;
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:30,代码来源:PhotoGpsServer.php

示例15: deleteInternal

    /**
     * Deletes this object from the database
     */
    protected function deleteInternal()
    {
        if ($this->instance === null) {
            parent::deleteInternal();
        }
        if ($this->table === null || $this->id_field === null) {
            return;
        }
        $id_field = new SwatDBField($this->id_field, 'integer');
        if (!property_exists($this, $id_field->name)) {
            return;
        }
        $id_ref = $id_field->name;
        $id = $this->{$id_ref};
        $instance_id = $this->instance === null ? null : $this->instance->id;
        if ($id !== null) {
            $sql = sprintf('delete from %s
				where %s = %s and instance %s %s', $this->table, $id_field->name, $id, SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
            SwatDB::exec($this->db, $sql);
        }
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:24,代码来源:PinholeInstanceDataObject.php


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