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


PHP SwatDB::equalityOperator方法代码示例

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


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

示例1: insertTag

    /**
     * Creates a new tag
     *
     * @throws SwatException if no database connection is set on this tag
     *                        entry control.
     */
    protected function insertTag($title, $index)
    {
        if ($this->app === null) {
            throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
        }
        // check to see if the tag already exists
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from
			BlorgTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgTagWrapper'));
        // only insert if no tag already exists (prevents creating two tags on
        // reloading)
        if (count($tags) > 0) {
            $tag = $tags->getFirst();
        } else {
            $tag = new BlorgTag();
            $tag->setDatabase($this->app->db);
            $tag->instance = $instance_id;
            $tag->title = $title;
            $tag->save();
            if (isset($this->app->memcache)) {
                $this->app->memcache->flushNs('tags');
            }
            $message = new SwatMessage(sprintf(Blorg::_('The tag “%s” has been added.'), $tag->title));
            $this->app->messages->add($message);
        }
        $this->tag_array[$tag->shortname] = $tag->title;
        $this->selected_tag_array[$tag->shortname] = $tag->title;
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:35,代码来源:BlorgTagEntry.php

示例2: getSegments

    protected function getSegments()
    {
        $sql = 'select * from MailingListCampaignSegment
			where %s and instance %s %s';
        $sql = sprintf($sql, $this->force_all ? '1 = 1' : sprintf('enabled = %s', $this->db->quote(true, 'boolean')), SwatDB::equalityOperator($this->getInstanceId()), $this->db->quote($this->getInstanceId(), 'integer'));
        return SwatDB::query($this->db, $sql, SwatDBClassMap::get('DeliveranceCampaignSegmentWrapper'));
    }
开发者ID:GervaisdeM,项目名称:deliverance,代码行数:7,代码来源:DeliveranceListCampaignSegmentCacheUpdater.php

示例3: load

    /**
     * Loads this comment
     *
     * @param integer $id the database id of this comment.
     * @param SiteInstance $instance optional. The instance to load the comment
     *                                in. If the application does not use
     *                                instances, this should be null. If
     *                                unspecified, the instance is not checked.
     *
     * @return boolean true if this comment and false if it was not.
     */
    public function load($id, SiteInstance $instance = null)
    {
        $this->checkDB();
        $loaded = false;
        $row = null;
        if ($this->table !== null && $this->id_field !== null) {
            $id_field = new SwatDBField($this->id_field, 'integer');
            $sql = sprintf('select %1$s.* from %1$s
				inner join PinholePhoto on %1$s.photo = PinholePhoto.id
				inner join ImageSet on ImageSet.id = PinholePhoto.image_set
				where %1$s.%2$s = %3$s', $this->table, $id_field->name, $this->db->quote($id, $id_field->type));
            $instance_id = $instance === null ? null : $instance->id;
            if ($instance_id !== null) {
                $sql .= sprintf(' and ImageSet.instance %s %s', SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
            }
            $rs = SwatDB::query($this->db, $sql, null);
            $row = $rs->fetchRow(MDB2_FETCHMODE_ASSOC);
        }
        if ($row !== null) {
            $this->initFromRow($row);
            $this->generatePropertyHashes();
            $loaded = true;
        }
        return $loaded;
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:36,代码来源:PinholeComment.php

示例4: getWhereClause

 protected function getWhereClause()
 {
     $where_clause = parent::getWhereClause();
     $instance_id = $this->app->getInstanceId();
     $where_clause .= sprintf(' and instance %s %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
     return $where_clause;
 }
开发者ID:nburka,项目名称:blorgy,代码行数:7,代码来源:Order.php

示例5: initSideBar

    protected function initSideBar()
    {
        $this->sidebar = new SiteSidebar();
        $gadget_instances = false;
        if (isset($this->app->memcache)) {
            $gadget_instances = $this->app->memcache->get('gadget_instances');
        }
        if ($gadget_instances === false) {
            $sql = sprintf('select * from GadgetInstance
				where instance %s %s
				order by displayorder', SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer'));
            $gadget_instances = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('SiteGadgetInstanceWrapper'));
            $gadget_instances->loadAllSubRecordsets('setting_values', SwatDBClassMap::get('SiteGadgetInstanceSettingValueWrapper'), 'GadgetInstanceSettingValue', 'gadget_instance');
            if (isset($this->app->memcache)) {
                $this->app->memcache->set('gadget_instances', $gadget_instances);
            }
        } else {
            $gadget_instances->setDatabase($this->app->db);
        }
        foreach ($gadget_instances as $gadget_instance) {
            $gadget = SiteGadgetFactory::get($this->app, $gadget_instance);
            $this->sidebar->add($gadget);
        }
        $this->sidebar->init();
    }
开发者ID:nburka,项目名称:blorgy,代码行数:25,代码来源:BlorgyLayout.php

示例6: buildInternal

    protected function buildInternal()
    {
        parent::buildInternal();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        $dep = new AdminListDependency();
        $dep->setTitle(Blorg::_('post'), Blorg::_('posts'));
        $sql = sprintf('select id, title, bodytext from BlorgPost
			where instance %s %s and id in (%s)
			order by publish_date desc, title', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $posts = SwatDB::query($this->app->db, $sql, 'BlorgPostWrapper');
        $entries = array();
        foreach ($posts as $post) {
            $entry = new AdminDependencyEntry();
            $entry->id = $post->id;
            $entry->title = $post->getTitle();
            $entry->status_level = AdminDependency::DELETE;
            $entry->parent = null;
            $entries[] = $entry;
        }
        $dep->entries = $entries;
        $message = $this->ui->getWidget('confirmation_message');
        $message->content = $dep->getMessage();
        $message->content_type = 'text/xml';
        if ($dep->getStatusLevelCount(AdminDependency::DELETE) == 0) {
            $this->switchToCancelButton();
        }
    }
开发者ID:nburka,项目名称:blorg,代码行数:28,代码来源:Delete.php

示例7: getTableModel

    /**
     * Gets the metadata for display
     *
     * @return SwatTableModel with metadata information.
     */
    protected function getTableModel(SwatView $view)
    {
        $sql = 'select * from PinholeMetaData
			where PinholeMetaData.instance %s %s
			order by %s';
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf($sql, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->getOrderByClause($view, 'visible desc, displayorder, title'));
        $metadata = SwatDB::query($this->app->db, $sql);
        $store = new SwatTableStore();
        foreach ($metadata as $data) {
            $ds = new SwatDetailsView();
            $ds->title = $data->title;
            $ds->shortname = $data->shortname;
            $ds->id = $data->id;
            $ds->visible = $data->visible;
            $ds->machine_tag = $data->machine_tag;
            if ($ds->visible) {
                $ds->group_title = 'Shown';
            } else {
                $ds->group_title = 'Not Shown';
            }
            $store->add($ds);
        }
        return $store;
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:30,代码来源:Index.php

示例8: getPhoto

    protected function getPhoto($filename)
    {
        $sql = sprintf('select PinholePhoto.*
			from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			where PinholePhoto.filename = %s and ImageSet.instance %s %s', $this->app->db->quote($filename, 'text'), SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer'));
        $wrapper_class = SwatDBClassMap::get('PinholePhotoWrapper');
        $photos = SwatDB::query($this->app->db, $sql, $wrapper_class);
        if (count($photos) == 0) {
            $instance = $this->app->getInstance();
            if ($instance === null) {
                $message = sprintf("Photo with filename '%s' does not exist.", $filename);
            } else {
                $message = sprintf("Photo with filename '%s' does not exist " . "in the instance '%s'.", $filename, $instance->shortname);
            }
            throw new SiteNotFoundException($message);
        }
        $photo = $photos->getFirst();
        if ($photo->private && !$this->app->session->isLoggedIn()) {
            $message = sprintf("Photo with filename '%s' is private and user " . "is not logged in.", $filename);
            throw new SiteNotFoundException($message);
        }
        $photo->setFileBase('../photos');
        return $photo;
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:25,代码来源:PinholePhotoLoaderPage.php

示例9: insertTag

    /**
     * Creates a new tag
     *
     * @throws SwatException if no database connection is set on this tag
     *                        entry control.
     */
    protected function insertTag($title, $index)
    {
        if ($this->app === null) {
            throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
        }
        // check to see if the tag already exists
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from
			PinholeTag where lower(title) = lower(%s)
				and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper'));
        // only insert if no tag already exists (prevents creating two tags on
        // reloading)
        if (count($tags) > 0) {
            $tag_obj = $tags->getFirst();
        } else {
            $tag_obj = new PinholeTagDataObject();
            $tag_obj->setDatabase($this->app->db);
            $tag_obj->instance = $instance_id;
            $tag_obj->title = $title;
            $tag_obj->save();
            $message = new SwatMessage(sprintf(Pinhole::_('“%s” tag has been added'), SwatString::minimizeEntities($tag_obj->title)));
            $message->content_type = 'text/xml';
            $message->secondary_content = sprintf(Pinhole::_('You can <a href="Tag/Edit?id=%d">edit this tag</a> ' . 'to customize it.'), $tag_obj->id);
            $this->app->messages->add($message);
        }
        $this->tag_array[$tag_obj->name] = $tag_obj->title;
        $this->selected_tag_array[$tag_obj->name] = $tag_obj->title;
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:35,代码来源:PinholePhotoTagEntry.php

示例10: __construct

    /**
     * Creates a new author index page
     *
     * @param SiteWebApplication $app the application.
     * @param SiteLayout $layout
     */
    public function __construct(SiteWebApplication $app, SiteLayout $layout, array $arguments = array())
    {
        parent::__construct($app, $layout, $arguments);
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from BlorgAuthor
			where instance %s %s and visible = %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->quote(true, 'boolean'));
        $this->authors = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgAuthorWrapper'));
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:14,代码来源:BlorgAuthorIndexPage.php

示例11: getArticles

    protected function getArticles()
    {
        $sql = sprintf('select title, shortname, description from Article
			where enabled = %s and visible = %s and parent is null
				and instance %s %s
			order by title asc', $this->app->db->quote(true, 'boolean'), $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer'));
        $wrapper = SwatDBClassMap::get('SiteArticleWrapper');
        return SwatDB::query($this->app->db, $sql, $wrapper);
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:9,代码来源:BlorgArticleGadget.php

示例12: validateShortname

    protected function validateShortname($shortname)
    {
        $sql = 'select shortname from BlorgTag
			where shortname = %s and id %s %s and instance %s %s';
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf($sql, $this->app->db->quote($shortname, 'text'), SwatDB::equalityOperator($this->id, true), $this->app->db->quote($this->id, 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $query = SwatDB::query($this->app->db, $sql);
        return count($query) == 0;
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:9,代码来源:Edit.php

示例13: validateShortname

    protected function validateShortname($shortname)
    {
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select count(id) from Article
			where shortname = %s and
				instance %s %s and
				parent %s %s
				and id %s %s', $this->app->db->quote($shortname, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), SwatDB::equalityOperator($this->parent), $this->app->db->quote($this->parent, 'integer'), SwatDB::equalityOperator($this->id, true), $this->app->db->quote($this->id, 'integer'));
        return SwatDB::queryOne($this->app->db, $sql) == 0;
    }
开发者ID:nburka,项目名称:blorgy,代码行数:10,代码来源:Edit.php

示例14: getWhereClause

 protected function getWhereClause()
 {
     if ($this->where_clause === null) {
         $where = parent::getWhereClause();
         $instance_id = $this->app->getInstanceId();
         $where .= sprintf(' and post in (select id from BlorgPost where instance %s %s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
         $this->where_clause = $where;
     }
     return $this->where_clause;
 }
开发者ID:nburka,项目名称:blorg,代码行数:10,代码来源:Index.php

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


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