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


PHP _elgg_cache_entity函数代码示例

本文整理汇总了PHP中_elgg_cache_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP _elgg_cache_entity函数的具体用法?PHP _elgg_cache_entity怎么用?PHP _elgg_cache_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: cache_entity

/**
 * Cache an entity.
 *
 * Stores an entity in $ENTITY_CACHE;
 *
 * @param ElggEntity $entity Entity to cache
 *
 * @return void
 * @access private
 * @deprecated 1.8
 */
function cache_entity(ElggEntity $entity)
{
    elgg_deprecated_notice('cache_entity() is a private function and should not be used.', 1.8);
    _elgg_cache_entity($entity);
}
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:16,代码来源:deprecated-1.8.php

示例2: elgg_solr_get_entity_guids


//.........这里部分代码省略.........
    $wheres[] = _elgg_get_entity_time_where_sql('e', $options['created_time_upper'], $options['created_time_lower'], $options['modified_time_upper'], $options['modified_time_lower']);
    // see if any functions failed
    // remove empty strings on successful functions
    foreach ($wheres as $i => $where) {
        if ($where === false) {
            return false;
        } elseif (empty($where)) {
            unset($wheres[$i]);
        }
    }
    // remove identical where clauses
    $wheres = array_unique($wheres);
    // evaluate join clauses
    if (!is_array($options['joins'])) {
        $options['joins'] = array($options['joins']);
    }
    // remove identical join clauses
    $joins = array_unique($options['joins']);
    foreach ($joins as $i => $join) {
        if ($join === false) {
            return false;
        } elseif (empty($join)) {
            unset($joins[$i]);
        }
    }
    // evalutate selects
    if ($options['selects']) {
        $selects = '';
        foreach ($options['selects'] as $select) {
            $selects .= ", {$select}";
        }
    } else {
        $selects = '';
    }
    if (!$options['count']) {
        $distinct = '';
        if ($options['require_distinct']) {
            $distinct = ' DISTINCT';
        }
        $query = "SELECT{$distinct} e.guid{$selects} FROM {$CONFIG->dbprefix}entities e ";
    } else {
        $query = "SELECT count(DISTINCT e.guid) as total FROM {$CONFIG->dbprefix}entities e ";
    }
    // add joins
    foreach ($joins as $j) {
        $query .= " {$j} ";
    }
    // add wheres
    $query .= ' WHERE ';
    foreach ($wheres as $w) {
        $query .= " {$w} AND ";
    }
    // Add access controls
    $query .= _elgg_get_access_where_sql();
    // reverse order by
    if ($options['reverse_order_by']) {
        $options['order_by'] = _elgg_sql_reverse_order_by_clause($options['order_by']);
    }
    if (!$options['count']) {
        if ($options['group_by']) {
            $query .= " GROUP BY {$options['group_by']}";
        }
        if ($options['order_by']) {
            $query .= " ORDER BY {$options['order_by']}";
        }
        if ($options['limit']) {
            $limit = sanitise_int($options['limit'], false);
            $offset = sanitise_int($options['offset'], false);
            $query .= " LIMIT {$offset}, {$limit}";
        }
        if ($options['callback'] === 'entity_row_to_elggstar') {
            $dt = _elgg_fetch_entities_from_sql($query, $options['__ElggBatch']);
        } else {
            $dt = get_data($query, $options['callback']);
        }
        if ($dt) {
            // populate entity and metadata caches
            $guids = array();
            foreach ($dt as $item) {
                // A custom callback could result in items that aren't ElggEntity's, so check for them
                if ($item instanceof ElggEntity) {
                    _elgg_cache_entity($item);
                    // plugins usually have only settings
                    if (!$item instanceof ElggPlugin) {
                        $guids[] = $item->guid;
                    }
                }
            }
            // @todo Without this, recursive delete fails. See #4568
            reset($dt);
            if ($guids) {
                _elgg_get_metadata_cache()->populateFromEntities($guids);
            }
        }
        return $dt;
    } else {
        $total = get_data_row($query);
        return (int) $total->total;
    }
}
开发者ID:ewinslow,项目名称:elgg_solr,代码行数:101,代码来源:functions.php

示例3: load

 /**
  * Load the \ElggUser data from the database
  *
  * @param mixed $guid \ElggUser GUID or \stdClass database row from entity table
  *
  * @return bool
  */
 protected function load($guid)
 {
     $attr_loader = new \Elgg\AttributeLoader(get_class(), 'user', $this->attributes);
     $attr_loader->secondary_loader = 'get_user_entity_as_row';
     $attrs = $attr_loader->getRequiredAttributes($guid);
     if (!$attrs) {
         return false;
     }
     $this->attributes = $attrs;
     $this->tables_loaded = 2;
     $this->loadAdditionalSelectValues($attr_loader->getAdditionalSelectValues());
     _elgg_cache_entity($this);
     return true;
 }
开发者ID:sephiroth88,项目名称:Elgg,代码行数:21,代码来源:ElggUser.php

示例4: load

 /**
  * Loads the full \ElggObject when given a guid.
  *
  * @param mixed $guid GUID of an \ElggObject or the \stdClass object from entities table
  *
  * @return bool
  * @throws InvalidClassException
  */
 protected function load($guid)
 {
     $attr_loader = new \Elgg\AttributeLoader(get_class(), 'object', $this->attributes);
     $attr_loader->requires_access_control = !$this instanceof \ElggPlugin;
     $attr_loader->secondary_loader = 'get_object_entity_as_row';
     $attrs = $attr_loader->getRequiredAttributes($guid);
     if (!$attrs) {
         return false;
     }
     $this->attributes = $attrs;
     $this->tables_loaded = 2;
     $this->loadAdditionalSelectValues($attr_loader->getAdditionalSelectValues());
     _elgg_cache_entity($this);
     return true;
 }
开发者ID:thehereward,项目名称:Elgg,代码行数:23,代码来源:ElggObject.php

示例5: load

 /**
  * Loads attributes from the entities table into the object.
  *
  * @param mixed $guid GUID of entity or \stdClass object from entities table
  *
  * @return bool
  */
 protected function load($guid)
 {
     if ($guid instanceof \stdClass) {
         $row = $guid;
     } else {
         $row = get_entity_as_row($guid);
     }
     if ($row) {
         // Create the array if necessary - all subclasses should test before creating
         if (!is_array($this->attributes)) {
             $this->attributes = array();
         }
         // Now put these into the attributes array as core values
         $objarray = (array) $row;
         foreach ($objarray as $key => $value) {
             $this->attributes[$key] = $value;
         }
         // Increment the portion counter
         if (!$this->isFullyLoaded()) {
             $this->tables_loaded++;
         }
         // guid needs to be an int  https://github.com/elgg/elgg/issues/4111
         $this->attributes['guid'] = (int) $this->attributes['guid'];
         // for BC with 1.8, ->subtype always returns ID, ->getSubtype() the string
         $this->attributes['subtype'] = (int) $this->attributes['subtype'];
         // Cache object handle
         if ($this->attributes['guid']) {
             _elgg_cache_entity($this);
         }
         return true;
     }
     return false;
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:40,代码来源:ElggEntity.php

示例6: getEntities


//.........这里部分代码省略.........
     // remove identical join clauses
     $joins = array_unique($options['joins']);
     foreach ($joins as $i => $join) {
         if ($join === false) {
             return false;
         } elseif (empty($join)) {
             unset($joins[$i]);
         }
     }
     // evalutate selects
     if ($options['selects']) {
         $selects = '';
         foreach ($options['selects'] as $select) {
             $selects .= ", {$select}";
         }
     } else {
         $selects = '';
     }
     if (!$options['count']) {
         $distinct = $options['distinct'] ? "DISTINCT" : "";
         $query = "SELECT {$distinct} e.*{$selects} FROM {$this->CONFIG->dbprefix}entities e ";
     } else {
         // note: when DISTINCT unneeded, it's slightly faster to compute COUNT(*) than GUIDs
         $count_expr = $options['distinct'] ? "DISTINCT e.guid" : "*";
         $query = "SELECT COUNT({$count_expr}) as total FROM {$this->CONFIG->dbprefix}entities e ";
     }
     // add joins
     foreach ($joins as $j) {
         $query .= " {$j} ";
     }
     // add wheres
     $query .= ' WHERE ';
     foreach ($wheres as $w) {
         $query .= " {$w} AND ";
     }
     // Add access controls
     $query .= _elgg_get_access_where_sql();
     // reverse order by
     if ($options['reverse_order_by']) {
         $options['order_by'] = _elgg_sql_reverse_order_by_clause($options['order_by']);
     }
     if ($options['count']) {
         $total = _elgg_services()->db->getDataRow($query);
         return (int) $total->total;
     }
     if ($options['group_by']) {
         $query .= " GROUP BY {$options['group_by']}";
     }
     if ($options['order_by']) {
         $query .= " ORDER BY {$options['order_by']}";
     }
     if ($options['limit']) {
         $limit = sanitise_int($options['limit'], false);
         $offset = sanitise_int($options['offset'], false);
         $query .= " LIMIT {$offset}, {$limit}";
     }
     if ($options['callback'] === 'entity_row_to_elggstar') {
         $results = _elgg_fetch_entities_from_sql($query, $options['__ElggBatch']);
     } else {
         $results = _elgg_services()->db->getData($query, $options['callback']);
     }
     if (!$results) {
         // no results, no preloading
         return $results;
     }
     // populate entity and metadata caches, and prepare $entities for preloader
     $guids = array();
     foreach ($results as $item) {
         // A custom callback could result in items that aren't \ElggEntity's, so check for them
         if ($item instanceof \ElggEntity) {
             _elgg_cache_entity($item);
             // plugins usually have only settings
             if (!$item instanceof \ElggPlugin) {
                 $guids[] = $item->guid;
             }
         }
     }
     // @todo Without this, recursive delete fails. See #4568
     reset($results);
     if ($guids) {
         // there were entities in the result set, preload metadata for them
         _elgg_services()->metadataCache->populateFromEntities($guids);
     }
     if (count($results) > 1) {
         $props_to_preload = [];
         if ($options['preload_owners']) {
             $props_to_preload[] = 'owner_guid';
         }
         if ($options['preload_containers']) {
             $props_to_preload[] = 'container_guid';
         }
         if ($props_to_preload) {
             // note, ElggEntityPreloaderIntegrationTest assumes it can swap out
             // the preloader after boot. If you inject this component at construction
             // time that unit test will break. :/
             _elgg_services()->entityPreloader->preload($results, $props_to_preload);
         }
     }
     return $results;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:101,代码来源:EntityTable.php

示例7: load

 /**
  * Load the ElggGroup data from the database
  *
  * @param mixed $guid GUID of an ElggGroup entity or database row from entity table
  *
  * @return bool
  */
 protected function load($guid)
 {
     $attr_loader = new ElggAttributeLoader(get_class(), 'group', $this->attributes);
     $attr_loader->requires_access_control = !$this instanceof ElggPlugin;
     $attr_loader->secondary_loader = 'get_group_entity_as_row';
     $attrs = $attr_loader->getRequiredAttributes($guid);
     if (!$attrs) {
         return false;
     }
     $this->attributes = $attrs;
     $this->attributes['tables_loaded'] = 2;
     _elgg_cache_entity($this);
     return true;
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:21,代码来源:ElggGroup.php

示例8: load

 /**
  * Load the ElggUser data from the database
  *
  * @param mixed $guid ElggUser GUID or stdClass database row from entity table
  *
  * @return bool
  */
 protected function load($guid)
 {
     $attr_loader = new ElggAttributeLoader(get_class(), 'user', $this->attributes);
     $attr_loader->secondary_loader = 'get_user_entity_as_row';
     $attrs = $attr_loader->getRequiredAttributes($guid);
     if (!$attrs) {
         return false;
     }
     $this->attributes = $attrs;
     $this->attributes['tables_loaded'] = 2;
     _elgg_cache_entity($this);
     return true;
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:20,代码来源:ElggUser.php

示例9: load

 /**
  * Loads attributes from the entities table into the object.
  *
  * @param mixed $guid GUID of entity or stdClass object from entities table
  *
  * @return bool
  */
 protected function load($guid)
 {
     if ($guid instanceof stdClass) {
         $row = $guid;
     } else {
         $row = get_entity_as_row($guid);
     }
     if ($row) {
         // Create the array if necessary - all subclasses should test before creating
         if (!is_array($this->attributes)) {
             $this->attributes = array();
         }
         // Now put these into the attributes array as core values
         $objarray = (array) $row;
         foreach ($objarray as $key => $value) {
             $this->attributes[$key] = $value;
         }
         // Increment the portion counter
         if (!$this->isFullyLoaded()) {
             $this->attributes['tables_loaded']++;
         }
         // guid needs to be an int  http://trac.elgg.org/ticket/4111
         $this->attributes['guid'] = (int) $this->attributes['guid'];
         // Cache object handle
         if ($this->attributes['guid']) {
             _elgg_cache_entity($this);
         }
         return true;
     }
     return false;
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:38,代码来源:ElggEntity.php


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