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


PHP FrmDb::get_col方法代码示例

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


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

示例1: show

 public static function show()
 {
     FrmAppHelper::permission_check('frm_view_reports');
     remove_action('frm_form_action_reports', 'FrmStatisticsController::list_reports');
     add_filter('frm_form_stop_action_reports', '__return_true');
     global $wpdb;
     $form = false;
     if (isset($_REQUEST['form'])) {
         $form = FrmForm::getOne($_REQUEST['form']);
     }
     if (!$form) {
         require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/select.php';
         return;
     }
     $exclude_types = FrmField::no_save_fields();
     $exclude_types = array_merge($exclude_types, array('rte', 'textarea', 'file', 'grid', 'signature', 'form', 'table'));
     $fields = FrmField::getAll(array('fi.form_id' => (int) $form->id, 'fi.type not' => $exclude_types), 'field_order');
     $js = '';
     $data = array();
     $colors = '#21759B,#EF8C08,#C6C6C6';
     $data['time'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent'));
     $data['month'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent', 'width' => '100%'), 'MONTH');
     foreach ($fields as $field) {
         $this_data = self::graph_shortcode(array('id' => $field->id, 'field' => $field, 'is3d' => true, 'min' => 0, 'colors' => $colors, 'width' => 650, 'bg_color' => 'transparent'));
         if (strpos($this_data, 'frm_no_data_graph') === false) {
             $data[$field->id] = $this_data;
         }
         unset($field, $this_data);
     }
     $entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('form_id' => $form->id), 'created_at');
     // trigger the scripts to load
     global $frm_vars;
     $frm_vars['forms_loaded'][] = true;
     include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/show.php';
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:35,代码来源:FrmProStatisticsController.php

示例2: is_duplicate

 /**
  * check for duplicate entries created in the last minute
  * @return boolean
  */
 public static function is_duplicate($new_values, $values)
 {
     if (defined('WP_IMPORTING') && WP_IMPORTING) {
         return false;
     }
     $duplicate_entry_time = apply_filters('frm_time_to_check_duplicates', 60, $new_values);
     if (empty($duplicate_entry_time)) {
         return false;
     }
     $check_val = $new_values;
     $check_val['created_at >'] = date('Y-m-d H:i:s', strtotime($new_values['created_at']) - absint($duplicate_entry_time));
     unset($check_val['created_at'], $check_val['updated_at']);
     unset($check_val['is_draft'], $check_val['id'], $check_val['item_key']);
     if ($new_values['item_key'] == $new_values['name']) {
         unset($check_val['name']);
     }
     global $wpdb;
     $entry_exists = FrmDb::get_col($wpdb->prefix . 'frm_items', $check_val, 'id', array('order_by' => 'created_at DESC'));
     if (!$entry_exists || empty($entry_exists) || !isset($values['item_meta'])) {
         return false;
     }
     $is_duplicate = false;
     foreach ($entry_exists as $entry_exist) {
         $is_duplicate = true;
         //add more checks here to make sure it's a duplicate
         $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
         $field_metas = array();
         foreach ($metas as $meta) {
             $field_metas[$meta->field_id] = $meta->meta_value;
         }
         // If prev entry is empty and current entry is not, they are not duplicates
         $filtered_vals = array_filter($values['item_meta']);
         if (empty($field_metas) && !empty($filtered_vals)) {
             return false;
         }
         $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
         foreach ($diff as $field_id => $meta_value) {
             if (!empty($meta_value)) {
                 $is_duplicate = false;
                 continue;
             }
         }
         if ($is_duplicate) {
             break;
         }
     }
     return $is_duplicate;
 }
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:52,代码来源:FrmEntry.php

示例3: form

 function form($form_action, $args = array())
 {
     global $wpdb;
     extract($args);
     $post_types = FrmProAppHelper::get_custom_post_types();
     if (!$post_types) {
         return;
     }
     $post_type = FrmProFormsHelper::post_type($args['values']['id']);
     $taxonomies = get_object_taxonomies($post_type);
     $action_control = $this;
     $echo = true;
     $form_id = $form->id;
     $display = false;
     $displays = array();
     $display_ids = FrmDb::get_col($wpdb->postmeta, array('meta_key' => 'frm_form_id', 'meta_value' => $form_id), 'post_ID');
     if ($display_ids) {
         $query_args = array('pm.meta_key' => 'frm_show_count', 'post_type' => 'frm_display', 'pm.meta_value' => array('dynamic', 'calendar', 'one'), 'p.post_status' => array('publish', 'private'), 'p.ID' => $display_ids);
         $displays = FrmDb::get_results($wpdb->posts . ' p LEFT JOIN ' . $wpdb->postmeta . ' pm ON (p.ID = pm.post_ID)', $query_args, 'p.ID, p.post_title', array('order_by' => 'p.post_title ASC'));
         if (isset($form_action->post_content['display_id'])) {
             // get view from settings
             if (is_numeric($form_action->post_content['display_id'])) {
                 $display = FrmProDisplay::getOne($form_action->post_content['display_id'], false, true);
             }
         } else {
             if (!is_numeric($form_action->post_content['post_content']) && !empty($display_ids)) {
                 // get auto view
                 $display = FrmProDisplay::get_form_custom_display($form_id);
                 if ($display) {
                     $display = FrmProDisplaysHelper::setup_edit_vars($display, true);
                 }
             }
         }
     }
     // Get array of all custom fields
     $custom_fields = array();
     if (isset($form_action->post_content['post_custom_fields'])) {
         foreach ($form_action->post_content['post_custom_fields'] as $custom_field_opts) {
             if (isset($custom_field_opts['meta_name'])) {
                 $custom_fields[] = $custom_field_opts['meta_name'];
             }
             unset($custom_field_opts);
         }
     }
     unset($display_ids);
     include dirname(__FILE__) . '/post_options.php';
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:47,代码来源:post_action.php

示例4: formidable_shortcode_atts

 public static function formidable_shortcode_atts($atts, $all_atts)
 {
     global $frm_vars, $wpdb;
     // reset globals
     $frm_vars['readonly'] = $atts['readonly'];
     $frm_vars['editing_entry'] = false;
     $frm_vars['show_fields'] = array();
     $frm_vars['editing_entry'] = false;
     if (!is_array($atts['fields'])) {
         $frm_vars['show_fields'] = explode(',', $atts['fields']);
     }
     if (!empty($atts['exclude_fields'])) {
         if (!is_array($atts['exclude_fields'])) {
             $atts['exclude_fields'] = explode(',', $atts['exclude_fields']);
         }
         $query = array('form_id' => (int) $atts['id'], 'id NOT' => $atts['exclude_fields'], 'field_key NOT' => $atts['exclude_fields']);
         $frm_vars['show_fields'] = FrmDb::get_col($wpdb->prefix . 'frm_fields', $query);
     }
     if ($atts['entry_id'] && $atts['entry_id'] == 'last') {
         $user_ID = get_current_user_id();
         if ($user_ID) {
             $frm_vars['editing_entry'] = FrmDb::get_var($wpdb->prefix . 'frm_items', array('form_id' => $atts['id'], 'user_id' => $user_ID), 'id', array('order_by' => 'created_at DESC'));
         }
     } else {
         if ($atts['entry_id']) {
             $frm_vars['editing_entry'] = $atts['entry_id'];
         }
     }
     foreach ($atts as $unset => $val) {
         if (is_array($all_atts) && isset($all_atts[$unset])) {
             unset($all_atts[$unset]);
         }
         unset($unset, $val);
     }
     if (is_array($all_atts)) {
         foreach ($all_atts as $att => $val) {
             $_GET[$att] = urlencode($val);
             unset($att, $val);
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:41,代码来源:FrmProFormsController.php

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

示例6: get_display_data


//.........这里部分代码省略.........
     if ($display->frm_show_count == 'one') {
         $display->frm_page_size = $display->frm_limit = '';
     }
     //don't keep current content if post type is frm_display
     if ($post && $post->post_type == self::$post_type) {
         $display->frm_insert_loc = '';
     }
     $pagination = '';
     $form_query = array('form_id' => $display->frm_form_id, 'post_id >' => 1);
     if ($extra_atts['drafts'] != 'both') {
         $is_draft = empty($extra_atts['drafts']) ? 0 : 1;
         $form_query['is_draft'] = $is_draft;
     } else {
         $is_draft = 'both';
     }
     if ($entry && $entry->form_id == $display->frm_form_id) {
         $form_query['id'] = $entry->id;
     }
     $form_posts = FrmDb::get_results('frm_items', $form_query, 'id, post_id');
     unset($form_query);
     $getting_entries = !$entry || !$post || empty($extra_atts['auto_id']);
     $check_filter_opts = !empty($display->frm_where) && $getting_entries;
     if ($entry && $entry->form_id == $display->frm_form_id) {
         $entry_ids = array($entry->id);
         // Filter by this entry ID to make query faster
         $use_ids = true;
     } else {
         if ($check_filter_opts || isset($_GET['frm_search'])) {
             //Only get $entry_ids if filters are set or if frm_search parameter is set
             $entry_query = array('form_id' => $display->frm_form_id);
             if ($extra_atts['drafts'] != 'both') {
                 $entry_query['is_draft'] = $is_draft;
             }
             $entry_ids = FrmDb::get_col('frm_items', $entry_query);
             unset($entry_query);
         }
     }
     $empty_msg = isset($display->frm_empty_msg) && !empty($display->frm_empty_msg) ? '<div class="frm_no_entries">' . FrmProFieldsHelper::get_default_value($display->frm_empty_msg, false) . '</div>' : '';
     if (isset($message)) {
         // if an entry was deleted above, show a message
         $empty_msg = $message . $empty_msg;
     }
     $after_where = false;
     $user_id = $extra_atts['user_id'];
     if (!empty($user_id)) {
         $user_id = FrmAppHelper::get_user_id_param($user_id);
         $uid_used = false;
     }
     self::add_group_by_filter($display, $getting_entries);
     unset($getting_entries);
     if ($check_filter_opts) {
         $display->frm_where = apply_filters('frm_custom_where_opt', $display->frm_where, array('display' => $display, 'entry' => $entry));
         $continue = false;
         foreach ($display->frm_where as $where_key => $where_opt) {
             $where_val = isset($display->frm_where_val[$where_key]) ? $display->frm_where_val[$where_key] : '';
             if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) {
                 $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true);
                 //if this param doesn't exist, then don't include it
                 if ($where_val == '') {
                     if (!$after_where) {
                         $continue = true;
                     }
                     continue;
                 }
             } else {
                 $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true);
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:67,代码来源:FrmProDisplaysController.php

示例7: get_search_ids

 public static function get_search_ids($s, $form_id, $args = array())
 {
     global $wpdb;
     if (empty($s)) {
         return false;
     }
     preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
     $search_terms = array_map('trim', $matches[0]);
     $spaces = '';
     $e_ids = $p_search = array();
     $search = array('or' => 1);
     $data_field = FrmProFormsHelper::has_field('data', $form_id, false);
     foreach ((array) $search_terms as $term) {
         $p_search[] = array($spaces . $wpdb->posts . '.post_title like' => $term, $spaces . $wpdb->posts . '.post_content like' => $term, 'or' => 1);
         $search[$spaces . 'meta_value like'] = $term;
         $spaces .= ' ';
         // add a space to keep the array keys unique
         if (is_numeric($term)) {
             $e_ids[] = (int) $term;
         }
         if ($data_field) {
             $df_form_ids = array();
             //search the joined entry too
             foreach ((array) $data_field as $df) {
                 FrmProFieldsHelper::get_subform_ids($df_form_ids, $df);
                 unset($df);
             }
             $data_form_ids = FrmDb::get_col($wpdb->prefix . 'frm_fields', array('id' => $df_form_ids), 'form_id');
             unset($df_form_ids);
             if ($data_form_ids) {
                 $data_entry_ids = FrmEntryMeta::getEntryIds(array('fi.form_id' => $data_form_ids, 'meta_value like' => $term));
                 if ($data_entry_ids) {
                     if (!isset($search['meta_value'])) {
                         $search['meta_value'] = array();
                     }
                     $search['meta_value'] = array_merge($search['meta_value'], $data_entry_ids);
                 }
             }
             unset($data_form_ids);
         }
     }
     $matching_posts = FrmDb::get_col($wpdb->posts, $p_search, 'ID');
     $p_ids = array($search, 'or' => 1);
     if ($matching_posts) {
         $post_ids = FrmDb::get_col($wpdb->prefix . 'frm_items', array('post_id' => $matching_posts, 'form_id' => (int) $form_id));
         if ($post_ids) {
             $p_ids['item_id'] = $post_ids;
         }
     }
     if (!empty($e_ids)) {
         $p_ids['item_id'] = $e_ids;
     }
     $query = array('fi.form_id' => $form_id);
     $query[] = $p_ids;
     return FrmEntryMeta::getEntryIds($query, '', '', true, $args);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:56,代码来源:FrmProEntriesHelper.php

示例8: destroy

 public function destroy($form_id = false, $type = 'default')
 {
     global $wpdb;
     $this->form_id = $form_id;
     $query = array('post_type' => FrmFormActionsController::$action_post_type);
     if ($form_id) {
         $query['menu_order'] = $form_id;
     }
     if ('all' != $type) {
         $query['post_excerpt'] = $this->id_base;
     }
     $post_ids = FrmDb::get_col($wpdb->posts, $query, 'ID');
     foreach ($post_ids as $id) {
         wp_delete_post($id);
     }
     self::clear_cache();
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:17,代码来源:FrmFormAction.php

示例9: csv

 /**
  * Export to CSV
  * @since 2.0.19
  */
 public static function csv($form_id = false, $search = '', $fid = '')
 {
     FrmAppHelper::permission_check('frm_view_entries');
     if (!$form_id) {
         $form_id = FrmAppHelper::get_param('form', '', 'get', 'sanitize_text_field');
         $search = FrmAppHelper::get_param(isset($_REQUEST['s']) ? 's' : 'search', '', 'get', 'sanitize_text_field');
         $fid = FrmAppHelper::get_param('fid', '', 'get', 'sanitize_text_field');
     }
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
         //Remove time limit to execute this function
         $mem_limit = str_replace('M', '', ini_get('memory_limit'));
         if ((int) $mem_limit < 256) {
             ini_set('memory_limit', '256M');
         }
     }
     global $wpdb;
     $form = FrmForm::getOne($form_id);
     $form_id = $form->id;
     $form_cols = self::get_fields_for_csv_export($form_id, $form);
     $item_id = FrmAppHelper::get_param('item_id', 0, 'get', 'sanitize_text_field');
     if (!empty($item_id)) {
         $item_id = explode(',', $item_id);
     }
     $query = array('form_id' => $form_id);
     if ($item_id) {
         $query['id'] = $item_id;
     }
     /**
      * Allows the query to be changed for fetching the entry ids to include in the export
      *
      * $query is the array of options to be filtered. It includes form_id, and maybe id (array of entry ids),
      * and the search query. This should return an array, but it can be handled as a string as well.
      */
     $query = apply_filters('frm_csv_where', $query, compact('form_id', 'search', 'fid', 'item_id'));
     $entry_ids = FrmDb::get_col($wpdb->prefix . 'frm_items it', $query);
     unset($query);
     if (empty($entry_ids)) {
         esc_html_e('There are no entries for that form.', 'formidable');
     } else {
         FrmCSVExportHelper::generate_csv(compact('form', 'entry_ids', 'form_cols'));
     }
     wp_die();
 }
开发者ID:hugocica,项目名称:locomotiva-2016,代码行数:48,代码来源:FrmXMLController.php

示例10: get_file_id

 public static function get_file_id($value)
 {
     global $wpdb;
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     foreach ((array) $value as $pos => $m) {
         $m = trim($m);
         if (empty($m)) {
             continue;
         }
         if (!is_numeric($m)) {
             //get the ID from the URL if on this site
             $m = FrmDb::get_col($wpdb->posts, array('guid' => $m), 'ID');
         }
         if (!is_numeric($m)) {
             unset($value[$pos]);
         } else {
             $value[$pos] = $m;
         }
         unset($pos);
         unset($m);
     }
     return $value;
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:25,代码来源:FrmProXMLHelper.php

示例11: _e

        ?>
: <?php 
        echo FrmProFieldsHelper::get_field_stats($field->id, 'average');
        ?>
</p>
            <p><?php 
        _e('Median', 'formidable');
        ?>
: <?php 
        echo FrmProFieldsHelper::get_field_stats($field->id, 'median');
        ?>
</p>
            <?php 
    } else {
        if ($field->type == 'user_id') {
            $user_ids = FrmDb::get_col($wpdb->users, array(), 'ID', 'display_name ASC');
            $submitted_user_ids = FrmEntryMeta::get_entry_metas_for_field($field->id, '', '', array('unique' => true));
            $not_submitted = array_diff($user_ids, $submitted_user_ids);
            ?>
            <p><?php 
            _e('Percent of users submitted', 'formidable');
            ?>
: <?php 
            echo round(count($submitted_user_ids) / count($user_ids) * 100, 2);
            ?>
%</p>
			<form action="<?php 
            echo esc_url(admin_url('user-edit.php'));
            ?>
" method="get">
            <p><?php 
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:31,代码来源:show.php

示例12: destroy_post

 public static function destroy_post($entry_id, $entry = false)
 {
     global $wpdb;
     if ($entry) {
         $post_id = $entry->post_id;
     } else {
         $post_id = FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $entry_id), 'post_id');
     }
     // delete child entries
     $child_entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('parent_item_id' => $entry_id));
     foreach ($child_entries as $child_entry) {
         FrmEntry::destroy($child_entry);
     }
     // Remove hook to make things consistent
     // Due to a WP bug, this hook won't be used for parent entry when there are child entries
     remove_action('frm_before_destroy_entry', 'FrmProFormActionsController::trigger_delete_actions', 20, 2);
     // Trigger delete actions for parent entry
     FrmProFormActionsController::trigger_delete_actions($entry_id, $entry);
     if ($post_id) {
         wp_delete_post($post_id);
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:22,代码来源:FrmProPost.php

示例13: _check_if_child_entries_moved

 /**
  * @covers FrmProFieldsHelper::move_entries_to_parent_form
  */
 function _check_if_child_entries_moved($args)
 {
     global $wpdb;
     // First check if old frm_items are gone from child form
     $items = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "frm_items WHERE form_id=" . $args['form_id']);
     $this->assertEmpty($items, 'Rows in wp_frm_items were not deleted when switching from repeating to non-repeating.');
     // Check if frm_item_metas were moved to parent entries
     $new_child_metas = FrmDb::get_col($wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_items it ON it.id=m.item_id', array('field_id' => $args['children']), 'it.form_id', array('order_by' => 'it.created_at ASC'));
     $this->assertNotEmpty($new_child_metas, 'No entries to check (when switching divider to non-repeatable).');
     foreach ($new_child_metas as $new_form_id) {
         $this->assertEquals($args['parent_form_id'], $new_form_id, 'Child entries are not moved to parent form (' . $args['parent_form_id'] . ') when a divider is switched from repeating to non-repeating.');
     }
     // Make sure frm_item_metas for repeating section are cleaned up
     $rep_meta_values = $wpdb->get_col("SELECT meta_value FROM " . $wpdb->prefix . "frm_item_metas WHERE field_id=" . $args['field_id']);
     $this->assertEmpty($rep_meta_values, 'frm_item_metas for repeating section were not deleted when switching to non-repeatable.');
     self::_check_if_child_form_deleted($args['form_id']);
 }
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:20,代码来源:test_FrmProFieldsControllerAjax.php

示例14: meta_through_join

 public static function meta_through_join($hide_field, $selected_field, $observed_field_val, $this_field = false, &$metas)
 {
     if (is_array($observed_field_val)) {
         $observed_field_val = array_filter($observed_field_val);
     }
     if (empty($observed_field_val) || !is_numeric($observed_field_val) && !is_array($observed_field_val)) {
         return;
     }
     $observed_info = FrmField::getOne($hide_field);
     if (!$selected_field || !$observed_info) {
         return;
     }
     $form_id = FrmProFieldsHelper::get_parent_form_id($selected_field);
     $join_fields = FrmField::get_all_types_in_form($form_id, 'data');
     if (empty($join_fields)) {
         return;
     }
     foreach ($join_fields as $jf) {
         if (isset($jf->field_options['form_select']) && isset($observed_info->field_options['form_select']) && $jf->field_options['form_select'] == $observed_info->field_options['form_select']) {
             $join_field = $jf->id;
         }
     }
     if (!isset($join_field)) {
         return;
     }
     $observed_field_val = array_filter((array) $observed_field_val);
     $query = array('field_id' => (int) $join_field);
     $sub_query = array('it.meta_value' => $observed_field_val);
     foreach ($observed_field_val as $obs_val) {
         $sub_query['or'] = 1;
         $sub_query['it.meta_value LIKE'] = ':"' . $obs_val . '"';
     }
     $query[] = $sub_query;
     $user_id = '';
     if ($this_field && isset($this_field->field_options['restrict']) && $this_field->field_options['restrict']) {
         $query['e.user_id'] = get_current_user_id();
     }
     // the ids of all the entries that have been selected in the linked form
     $entry_ids = FrmEntryMeta::getEntryIds($query);
     if (!empty($entry_ids)) {
         if ($form_id != $selected_field->form_id) {
             // this is a child field so we need to get the child entries
             global $wpdb;
             $entry_ids = FrmDb::get_col($wpdb->prefix . 'frm_items', array('parent_item_id' => $entry_ids));
         }
         if (!empty($entry_ids)) {
             $metas = FrmEntryMeta::getAll(array('item_id' => $entry_ids, 'field_id' => $selected_field->id), ' ORDER BY meta_value');
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:50,代码来源:FrmProEntryMetaHelper.php

示例15: get_ajax_time_options

 private static function get_ajax_time_options($values, array &$remove)
 {
     $time_key = str_replace('field_', '', $values['time_field']);
     $date_key = str_replace('field_', '', $values['date_field']);
     $values['date'] = FrmProAppHelper::maybe_convert_to_db_date($values['date'], 'Y-m-d');
     $date_entries = FrmEntryMeta::getEntryIds(array('fi.field_key' => $date_key, 'meta_value' => $values['date']));
     $remove = apply_filters('frm_allowed_times', $remove, $values);
     if (!$date_entries || empty($date_entries)) {
         return;
     }
     global $wpdb;
     $query = array('fi.field_key' => $time_key, 'it.item_id' => $date_entries);
     if (isset($values['entry_id']) && is_numeric($values['entry_id'])) {
         $query['it.item_id !'] = $values['entry_id'];
     }
     $used_times = FrmDb::get_col($wpdb->prefix . 'frm_item_metas it LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $query, 'meta_value');
     if (!$used_times || empty($used_times)) {
         return;
     }
     $number_allowed = apply_filters('frm_allowed_time_count', 1, $time_key, $date_key);
     $count = array();
     foreach ($used_times as $used) {
         if (isset($remove[$used])) {
             continue;
         }
         if (!isset($count[$used])) {
             $count[$used] = 0;
         }
         $count[$used]++;
         if ((int) $count[$used] >= $number_allowed) {
             $remove[$used] = $used;
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:34,代码来源:FrmProFieldsController.php


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