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


PHP FrmAppHelper::set_cache方法代码示例

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


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

示例1: format_field_results

 /**
  * @since 2.0.8
  */
 private static function format_field_results(&$results)
 {
     if (is_array($results)) {
         foreach ($results as $r_key => $result) {
             FrmAppHelper::set_cache($result->id, $result, 'frm_field');
             FrmAppHelper::set_cache($result->field_key, $result, 'frm_field');
             $results[$r_key]->field_options = maybe_unserialize($result->field_options);
             $results[$r_key]->options = maybe_unserialize($result->options);
             $results[$r_key]->default_value = maybe_unserialize($result->default_value);
             unset($r_key, $result);
         }
     } else {
         if ($results) {
             FrmAppHelper::set_cache($results->id, $results, 'frm_field');
             FrmAppHelper::set_cache($results->field_key, $results, 'frm_field');
             self::prepare_options($results);
         }
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:22,代码来源:FrmField.php

示例2: search_entry_metas

 public static function search_entry_metas($search, $field_id = '', $operator)
 {
     $cache_key = 'search_' . maybe_serialize($search) . $field_id . $operator;
     $results = wp_cache_get($cache_key, 'frm_entry');
     if (false !== $results) {
         return $results;
     }
     global $wpdb;
     if (is_array($search)) {
         $where = '';
         foreach ($search as $field => $value) {
             if ($value <= 0 || !in_array($field, array('year', 'month', 'day'))) {
                 continue;
             }
             switch ($field) {
                 case 'year':
                     $value = '%' . $value;
                     break;
                 case 'month':
                     $value .= '%';
                     break;
                 case 'day':
                     $value = '%' . $value . '%';
             }
             $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value);
         }
         $where .= $wpdb->prepare(' field_id=%d', $field_id);
         $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
     } else {
         if ($operator == 'LIKE') {
             $search = '%' . $search . '%';
         }
         $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
     }
     $results = $wpdb->get_col($query, 0);
     FrmAppHelper::set_cache($cache_key, $results, 'frm_entry');
     return $results;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:38,代码来源:FrmEntryMeta.php

示例3: wp_cache_get

 /**
  * @return int count of forms
  */
 public static function &get_count()
 {
     global $wpdb;
     $cache_key = 'frm_form_counts';
     $counts = wp_cache_get($cache_key, 'frm_form');
     if (false !== $counts) {
         return $counts;
     }
     $results = (array) FrmDb::get_results('frm_forms', array('or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0), 'status, is_template');
     $statuses = array('published', 'draft', 'template', 'trash');
     $counts = array_fill_keys($statuses, 0);
     foreach ($results as $row) {
         if ('trash' != $row->status) {
             if ($row->is_template) {
                 $counts['template']++;
             } else {
                 $counts['published']++;
             }
         } else {
             $counts['trash']++;
         }
         if ('draft' == $row->status) {
             $counts['draft']++;
         }
         unset($row);
     }
     $counts = (object) $counts;
     FrmAppHelper::set_cache($cache_key, $counts, 'frm_form');
     return $counts;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:33,代码来源:FrmForm.php

示例4: getAll

 public static function getAll($where, $order_by = '', $limit = '', $meta = false, $inc_form = true)
 {
     global $wpdb;
     $limit = FrmAppHelper::esc_limit($limit);
     $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
     $entries = wp_cache_get($cache_key, 'frm_entry');
     if (false === $entries) {
         $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
         $table = $wpdb->prefix . 'frm_items it ';
         if ($inc_form) {
             $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
             $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
         }
         if (preg_match('/ meta_([0-9]+)/', $order_by, $order_matches)) {
             // sort by a requested field
             $field_id = (int) $order_matches[1];
             $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
             unset($order_matches, $field_id);
         }
         // prepare the query
         $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
         $entries = $wpdb->get_results($query, OBJECT_K);
         unset($query);
         FrmAppHelper::set_cache($cache_key, $entries, 'frm_entry');
     }
     if (!$meta || !$entries) {
         return stripslashes_deep($entries);
     }
     unset($meta);
     if (!is_array($where) && preg_match('/^it\\.form_id=\\d+$/', $where)) {
         $where = array('it.form_id' => substr($where, 11));
     }
     $meta_where = array('field_id !' => 0);
     if ($limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id'])) {
         $meta_where['fi.form_id'] = $where['it.form_id'];
     } else {
         $meta_where['item_id'] = array_keys($entries);
     }
     $metas = FrmDb::get_results($wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id');
     unset($meta_where);
     if (!$metas) {
         return stripslashes_deep($entries);
     }
     foreach ($metas as $m_key => $meta_val) {
         if (!isset($entries[$meta_val->item_id])) {
             continue;
         }
         if (!isset($entries[$meta_val->item_id]->metas)) {
             $entries[$meta_val->item_id]->metas = array();
         }
         $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize($meta_val->meta_value);
         unset($m_key, $meta_val);
     }
     if (!FrmAppHelper::prevent_caching()) {
         foreach ($entries as $entry) {
             FrmAppHelper::set_cache($entry->id, $entry, 'frm_entry');
             unset($entry);
         }
     }
     return stripslashes_deep($entries);
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:61,代码来源:FrmEntry.php


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