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


PHP FrmDb::append_where_is方法代码示例

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


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

示例1: prepare_post_filter

 /**
  * if there are posts linked to entries for this form
  */
 private static function prepare_post_filter($args, $where_field, &$new_ids)
 {
     if (empty($args['form_posts'])) {
         // there are not posts related to this view
         return;
     }
     if (!isset($where_field->field_options['post_field']) || !in_array($where_field->field_options['post_field'], array('post_category', 'post_custom', 'post_status', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date'))) {
         // this is not a post field
         return;
     }
     $post_ids = array();
     foreach ($args['form_posts'] as $form_post) {
         $post_ids[$form_post->post_id] = $form_post->id;
         if (!in_array($form_post->id, $new_ids)) {
             $new_ids[] = $form_post->id;
         }
     }
     if (empty($post_ids)) {
         return;
     }
     global $wpdb;
     $filter_args = array();
     if ($where_field->field_options['post_field'] == 'post_category') {
         //check categories
         $args['temp_where_is'] = FrmDb::append_where_is(str_replace(array('!', 'not '), '', $args['where_is']));
         $t_where = array('or' => 1, 't.term_id ' . $args['temp_where_is'] => $args['where_val'], 't.slug ' . $args['temp_where_is'] => $args['where_val'], 't.name ' . $args['temp_where_is'] => $args['where_val']);
         unset($args['temp_where_is']);
         $query = array('tt.taxonomy' => $where_field->field_options['taxonomy']);
         $query[] = $t_where;
         self::add_group_by($filter_args, $args, 'tr.object_id');
         $add_posts = FrmDb::get_col($wpdb->terms . ' AS t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON tt.term_id = t.term_id INNER JOIN ' . $wpdb->term_relationships . ' AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id', $query, 'tr.object_id', $filter_args);
         $add_posts = array_intersect($add_posts, array_keys($post_ids));
         if (in_array($args['where_is'], array('!=', 'not LIKE'))) {
             $remove_posts = $add_posts;
             $add_posts = false;
         } else {
             if (empty($add_posts)) {
                 $new_ids = array();
                 return;
             }
         }
     } else {
         $query = array();
         if ($where_field->field_options['post_field'] == 'post_custom' && $where_field->field_options['custom_field'] != '') {
             //check custom fields
             $get_field = 'post_id';
             $get_table = $wpdb->postmeta;
             $query['meta_key'] = $where_field->field_options['custom_field'];
             $query_key = 'meta_value';
         } else {
             //if field is post field
             $get_field = 'ID';
             $get_table = $wpdb->posts;
             $query_key = sanitize_title($where_field->field_options['post_field']);
         }
         self::add_group_by($filter_args, $args, $query_key);
         $query_key .= (in_array($where_field->type, array('number', 'scale')) ? ' +0 ' : ' ') . FrmDb::append_where_is($args['where_is']);
         $query[$query_key] = $args['where_val'];
         $add_posts = FrmDb::get_col($get_table, $query, $get_field, $filter_args);
         $add_posts = array_intersect($add_posts, array_keys($post_ids));
     }
     if ($add_posts && !empty($add_posts)) {
         $new_ids = array();
         foreach ($add_posts as $add_post) {
             if (!in_array($post_ids[$add_post], $new_ids)) {
                 $new_ids[] = $post_ids[$add_post];
             }
         }
     }
     if (isset($remove_posts)) {
         if (!empty($remove_posts)) {
             foreach ($remove_posts as $remove_post) {
                 $key = array_search($post_ids[$remove_post], $new_ids);
                 if ($key && $new_ids[$key] == $post_ids[$remove_post]) {
                     unset($new_ids[$key]);
                 }
                 unset($key);
             }
         }
     } else {
         if (!$add_posts) {
             $new_ids = array();
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:88,代码来源:FrmProAppHelper.php

示例2: get_display_data


//.........这里部分代码省略.........
                 $where_val = explode(',', $where_val);
                 $where_val = array_filter($where_val);
             }
             if (is_array($where_val) && !empty($where_val)) {
                 if (strpos($display->frm_where_is[$where_key], '!') === false && strpos($display->frm_where_is[$where_key], 'not') === false) {
                     $display->frm_where_is[$where_key] = ' in ';
                 } else {
                     $display->frm_where_is[$where_key] = 'not in';
                 }
             }
             if (is_numeric($where_opt)) {
                 $filter_opts = apply_filters('frm_display_filter_opt', array('where_opt' => $where_opt, 'where_is' => $display->frm_where_is[$where_key], 'where_val' => $where_val, 'form_id' => $display->frm_form_id, 'form_posts' => $form_posts, 'after_where' => $after_where, 'display' => $display, 'drafts' => $is_draft, 'use_ids' => $use_ids));
                 $entry_ids = FrmProAppHelper::filter_where($entry_ids, $filter_opts);
                 unset($filter_opts);
                 $after_where = true;
                 $continue = false;
                 if (empty($entry_ids)) {
                     break;
                 }
             } else {
                 if (in_array($where_opt, array('created_at', 'updated_at'))) {
                     if ($where_val == 'NOW') {
                         $where_val = current_time('mysql', 1);
                     }
                     if (strpos($display->frm_where_is[$where_key], 'LIKE') === false) {
                         $where_val = date('Y-m-d H:i:s', strtotime($where_val));
                         // If using less than or equal to, set the time to the end of the day
                         if ($display->frm_where_is[$where_key] == '<=') {
                             $where_val = str_replace('00:00:00', '23:59:59', $where_val);
                         }
                         // Convert date to GMT since that is the format in the DB
                         $where_val = get_gmt_from_date($where_val);
                     }
                     $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val;
                     $continue = true;
                 } else {
                     if (in_array($where_opt, array('id', 'item_key', 'post_id', 'ip'))) {
                         $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val;
                         // Update entry IDs if the entry ID filter is set to "equal to"
                         if ($where_opt == 'id' && in_array($display->frm_where_is[$where_key], array('=', ' in '))) {
                             $entry_ids = $where_val;
                         }
                         $continue = true;
                     }
                 }
             }
         }
         if (!$continue && empty($entry_ids)) {
             if ($display->frm_insert_loc == 'after') {
                 $content .= $empty_msg;
             } else {
                 if ($display->frm_insert_loc == 'before') {
                     $content = $empty_msg . $content;
                 } else {
                     if ($filter) {
                         $empty_msg = apply_filters('the_content', $empty_msg);
                     }
                     if ($post && $post->post_type == self::$post_type && in_the_loop()) {
                         $content = '';
                     }
                     $content .= $empty_msg;
                 }
             }
             return $content;
         }
     }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:67,代码来源:FrmProDisplaysController.php

示例3: get_field_matches

 public static function get_field_matches($args)
 {
     extract($args);
     $f = $orig_f;
     $where_is = '=';
     //If using <, >, <=, >=, or != TODO: %, !%.
     //Note: $f will be numeric if using <, >, <=, >=, != OR if using x=val, but the code in the if/else statement will not actually do anything to x=val.
     if (is_numeric($f)) {
         //Note: $f will count up for certain atts
         $orig_val = $val;
         $lpos = strpos($val, '<');
         $gpos = strpos($val, '>');
         $not_pos = strpos($val, '!=');
         $dash_pos = strpos($val, '-');
         if ($not_pos !== false) {
             //If string contains !=
             //If entry IDs have not been set by a previous $atts
             if (empty($entry_ids) && $after_where == 0) {
                 $query = array('form_id' => $field->form_id);
                 //By default, don't get drafts
                 if ($drafts != 'both') {
                     $query['is_draft'] = $drafts;
                 }
                 $entry_ids = FrmDb::get_col('frm_items', $query);
                 unset($query);
             }
             $where_is = '!=';
             $str = explode($where_is, $orig_val);
             $f = $str[0];
             $val = $str[1];
         } else {
             if ($lpos !== false || $gpos !== false) {
                 //If string contains greater than or less than
                 $where_is = $gpos !== false && $lpos !== false && $lpos > $gpos || $lpos === false ? '>' : '<';
                 $str = explode($where_is, $orig_val);
                 if (count($str) == 2) {
                     $f = $str[0];
                     $val = $str[1];
                 } else {
                     if (count($str) == 3) {
                         //3 parts assumes a structure like '-1 month'<255<'1 month'
                         $val = str_replace($str[0] . $where_is, '', $orig_val);
                         $entry_ids = self::get_field_matches(compact('entry_ids', 'orig_f', 'val', 'id', 'atts', 'field', 'form_posts', 'after_where', 'drafts'));
                         $after_where = true;
                         $f = $str[1];
                         $val = $str[0];
                         $where_is = $where_is == '<' ? '>' : '<';
                     }
                 }
                 if (strpos($val, '=') === 0) {
                     $where_is .= '=';
                     $val = substr($val, 1);
                 }
                 // If field key contains a dash, then it won't be put in as $f automatically (WordPress quirk maybe?)
                 // Use $f < 5 to decrease the likelihood of this section being used when $f is a field ID (like x=val)
             } else {
                 if ($dash_pos !== false && strpos($val, '=') !== false && $f < 5) {
                     $str = explode($where_is, $orig_val);
                     $f = $str[0];
                     $val = $str[1];
                 }
             }
         }
     }
     // If this function has looped through at least once, and there aren't any entry IDs
     if ($after_where && !$entry_ids) {
         return array();
     }
     //If using field key
     if (!is_numeric($f)) {
         if (in_array($f, array('created_at', 'updated_at'))) {
             global $wpdb;
             $val = FrmAppHelper::replace_quotes($val);
             $val = str_replace(array('"', "'"), "", $val);
             $val = date('Y-m-d', strtotime($val));
             $query = array('form_id' => $field->form_id, $f . FrmDb::append_where_is($where_is) => $val);
             // Entry IDs may be set even if after_where isn't true
             if ($entry_ids) {
                 $query['id'] = $entry_ids;
             }
             $entry_ids = FrmDb::get_col('frm_items', $query);
             return $entry_ids;
         } else {
             //check for field keys
             $this_field = FrmField::getOne($f);
             if ($this_field) {
                 $f = $this_field->id;
             } else {
                 //If no field ID
                 return $entry_ids;
             }
             unset($this_field);
         }
     }
     unset($orig_f);
     //Prepare val
     $val = FrmAppHelper::replace_quotes($val);
     $val = trim(trim($val, "'"), '"');
     $where_atts = apply_filters('frm_stats_where', array('where_is' => $where_is, 'where_val' => $val), array('id' => $id, 'atts' => $atts));
     $val = $where_atts['where_val'];
//.........这里部分代码省略.........
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:101,代码来源:FrmProFieldsHelper.php

示例4: get_dynamic_field_entry_id

 /**
  * Get the entry ID from a linked field
  *
  * @since 2.0.15
  * @param int $linked_field_id
  * @param string $where_val
  * @param string $where_is
  * @return int $linked_id
  */
 public static function get_dynamic_field_entry_id($linked_field_id, $where_val, $where_is)
 {
     $query = array('field_id' => $linked_field_id, 'meta_value' . FrmDb::append_where_is($where_is) => $where_val);
     $linked_id = FrmDb::get_col('frm_item_metas', $query, 'item_id');
     return $linked_id;
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:15,代码来源:FrmProField.php


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