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


PHP FrmAppHelper::esc_limit方法代码示例

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


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

示例1: 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);
         if (!FrmAppHelper::prevent_caching()) {
             wp_cache_set($cache_key, $entries, 'frm_entry', 300);
         }
     }
     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) {
             wp_cache_set($entry->id, $entry, 'frm_entry');
             unset($entry);
         }
     }
     return stripslashes_deep($entries);
 }
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:63,代码来源:FrmEntry.php

示例2: getAll

 public static function getAll($where = array(), $order_by = '', $limit = '', $blog_id = false)
 {
     $cache_key = maybe_serialize($where) . $order_by . 'l' . $limit . 'b' . $blog_id;
     if (self::$use_cache) {
         // make sure old cache doesn't get saved as a transient
         $results = wp_cache_get($cache_key, 'frm_field');
         if (false !== $results) {
             return stripslashes_deep($results);
         }
     }
     global $wpdb;
     if ($blog_id && is_multisite()) {
         global $wpmuBaseTablePrefix;
         if ($wpmuBaseTablePrefix) {
             $prefix = $wpmuBaseTablePrefix . $blog_id . '_';
         } else {
             $prefix = $wpdb->get_blog_prefix($blog_id);
         }
         $table_name = $prefix . 'frm_fields';
         $form_table_name = $prefix . 'frm_forms';
     } else {
         $table_name = $wpdb->prefix . 'frm_fields';
         $form_table_name = $wpdb->prefix . 'frm_forms';
     }
     if (!empty($order_by) && strpos($order_by, 'ORDER BY') === false) {
         $order_by = ' ORDER BY ' . $order_by;
     }
     $limit = FrmAppHelper::esc_limit($limit);
     $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
     $query_type = $limit == ' LIMIT 1' || $limit == 1 ? 'row' : 'results';
     if (is_array($where)) {
         if (isset($where['fi.form_id']) && count($where) == 1) {
             // add sub fields to query
             $form_id = $where['fi.form_id'];
             $where[] = array('or' => 1, 'fi.form_id' => $form_id, 'fr.parent_form_id' => $form_id);
             unset($where['fi.form_id']);
         }
         $results = FrmDb::get_var($table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array('order_by' => $order_by, 'limit' => $limit), '', $query_type);
     } else {
         // if the query is not an array, then it has already been prepared
         $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
         $function_name = $query_type == 'row' ? 'get_row' : 'get_results';
         $results = $wpdb->{$function_name}($query);
     }
     unset($where);
     self::format_field_results($results);
     wp_cache_set($cache_key, $results, 'frm_field', 300);
     return stripslashes_deep($results);
 }
开发者ID:EyesX,项目名称:formidable-forms,代码行数:49,代码来源:FrmField.php

示例3: convert_options_to_array

 private static function convert_options_to_array(&$args, $order_by = '', $limit = '')
 {
     if (!is_array($args)) {
         $args = array('order_by' => $args);
     }
     if (!empty($order_by)) {
         $args['order_by'] = $order_by;
     }
     if (!empty($limit)) {
         $args['limit'] = $limit;
     }
     $temp_args = $args;
     foreach ($temp_args as $k => $v) {
         if ($v == '') {
             unset($args[$k]);
             continue;
         }
         if ($k == 'limit') {
             $args[$k] = FrmAppHelper::esc_limit($v);
         }
         $db_name = strtoupper(str_replace('_', ' ', $k));
         if (strpos($v, $db_name) === false) {
             $args[$k] = $db_name . ' ' . $v;
         }
     }
     // Make sure LIMIT is the last argument
     if (isset($args['order_by']) && isset($args['limit'])) {
         $temp_limit = $args['limit'];
         unset($args['limit']);
         $args['limit'] = $temp_limit;
     }
 }
开发者ID:hugocica,项目名称:locomotiva-2016,代码行数:32,代码来源:FrmDb.php

示例4: getAll

 /**
  * @return object|array of objects
  */
 public static function getAll($where = array(), $order_by = '', $limit = '')
 {
     if (is_array($where) && !empty($where)) {
         $results = FrmDb::get_results('frm_forms', $where, '*', array('order_by' => $order_by, 'limit' => $limit));
     } else {
         global $wpdb;
         // the query has already been prepared if this is not an array
         $query = 'SELECT * FROM ' . $wpdb->prefix . 'frm_forms' . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . FrmAppHelper::esc_order($order_by) . FrmAppHelper::esc_limit($limit);
         $results = $wpdb->get_results($query);
     }
     if ($results) {
         foreach ($results as $result) {
             wp_cache_set($result->id, $result, 'frm_form');
             $result->options = maybe_unserialize($result->options);
         }
     }
     if ($limit == ' LIMIT 1' || $limit == 1) {
         // return the first form object if we are only getting one form
         $results = reset($results);
     }
     return stripslashes_deep($results);
 }
开发者ID:mazykin46,项目名称:portfolio,代码行数:25,代码来源:FrmForm.php


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