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


PHP FrmDb::get_where_clause_and_values方法代码示例

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


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

示例1: move_entries_to_child_form

 /**
  * Move entries from parent form to child form
  *
  * @since 2.0.09
  */
 private static function move_entries_to_child_form($args)
 {
     global $wpdb;
     // get the ids of the entries saved in these fields
     $item_ids = FrmDb::get_col('frm_item_metas', array('field_id' => $args['children']), 'item_id', array('group_by' => 'item_id'));
     foreach ($item_ids as $old_id) {
         // Create a new entry in the child form
         $new_id = FrmEntry::create(array('form_id' => $args['form_id'], 'parent_item_id' => $old_id));
         // Move the parent item_metas to the child form
         $where = array('item_id' => $old_id, 'field_id' => $args['children']);
         FrmDb::get_where_clause_and_values($where);
         array_unshift($where['values'], $new_id);
         $c = $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'frm_item_metas SET item_id = %d ' . $where['where'], $where['values']));
         if ($c) {
             // update the section field meta with the new entry ID
             $u = FrmEntryMeta::update_entry_meta($old_id, $args['field_id'], null, $new_id);
             if (!$u) {
                 // add the row if it wasn't there to update
                 FrmEntryMeta::add_entry_meta($old_id, $args['field_id'], null, $new_id);
             }
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:28,代码来源:FrmProFieldsHelper.php

示例2: update_entry_metas

 public static function update_entry_metas($entry_id, $values)
 {
     global $wpdb;
     $prev_values = FrmDb::get_col($wpdb->prefix . 'frm_item_metas', array('item_id' => $entry_id, 'field_id !' => 0), 'field_id');
     foreach ($values as $field_id => $meta_value) {
         // set the value for the file upload field and add new tags (in Pro version)
         $values = apply_filters('frm_prepare_data_before_db', $values, $field_id, $entry_id);
         if ($prev_values && in_array($field_id, $prev_values)) {
             if (is_array($meta_value) && empty($meta_value) || !is_array($meta_value) && trim($meta_value) == '') {
                 // remove blank fields
                 unset($values[$field_id]);
             } else {
                 // if value exists, then update it
                 self::update_entry_meta($entry_id, $field_id, '', $values[$field_id]);
             }
         } else {
             // if value does not exist, then create it
             self::add_entry_meta($entry_id, $field_id, '', $values[$field_id]);
         }
     }
     if (empty($prev_values)) {
         return;
     }
     $prev_values = array_diff($prev_values, array_keys($values));
     if (empty($prev_values)) {
         return;
     }
     // prepare the query
     $where = array('item_id' => $entry_id, 'field_id' => $prev_values);
     FrmDb::get_where_clause_and_values($where);
     // Delete any leftovers
     $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values']));
     self::clear_cache();
 }
开发者ID:mazykin46,项目名称:portfolio,代码行数:34,代码来源:FrmEntryMeta.php

示例3: prepend_and_or_where

 public static function prepend_and_or_where($starts_with = ' WHERE ', $where = '')
 {
     if (empty($where)) {
         return '';
     }
     if (is_array($where)) {
         global $wpdb;
         FrmDb::get_where_clause_and_values($where, $starts_with);
         $where = $wpdb->prepare($where['where'], $where['values']);
     } else {
         $where = $starts_with . $where;
     }
     return $where;
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:14,代码来源:FrmAppHelper.php

示例4: get_records

 function get_records($table, $args = array(), $order_by = '', $limit = '', $fields = '*')
 {
     global $wpdb;
     extract(FrmDb::get_where_clause_and_values($args));
     if (!empty($order_by)) {
         $order_by = " ORDER BY {$order_by}";
     }
     if (!empty($limit)) {
         $limit = " LIMIT {$limit}";
     }
     $query = "SELECT {$fields} FROM {$table}{$where}{$order_by}{$limit}";
     $query = $wpdb->prepare($query, $values);
     return $wpdb->get_results($query);
 }
开发者ID:moscarar,项目名称:cityhow,代码行数:14,代码来源:FrmDb.php

示例5: add_where_to_query

 /**
  * @since 2.0.8
  */
 private static function add_where_to_query($add_where, &$where_clause)
 {
     if (is_array($where_clause)) {
         $where_clause[] = $add_where;
     } else {
         global $wpdb;
         $where = '';
         $values = array();
         FrmDb::parse_where_from_array($add_where, '', $where, $values);
         FrmDb::get_where_clause_and_values($add_where);
         $where_clause .= ' AND (' . $wpdb->prepare($where, $values) . ')';
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:16,代码来源:FrmProEntriesHelper.php

示例6: set_status

 /**
  * @param string $status
  * @return int|boolean
  */
 public static function set_status($id, $status)
 {
     if ('trash' == $status) {
         return self::trash($id);
     }
     $statuses = array('published', 'draft', 'trash');
     if (!in_array($status, $statuses)) {
         return false;
     }
     global $wpdb;
     if (is_array($id)) {
         $where = array('id' => $id);
         FrmDb::get_where_clause_and_values($where);
         array_unshift($where['values'], $status);
         $query_results = $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values']));
     } else {
         $query_results = $wpdb->update($wpdb->prefix . 'frm_forms', array('status' => $status), array('id' => $id));
     }
     if ($query_results) {
         self::clear_form_cache();
     }
     return $query_results;
 }
开发者ID:mazykin46,项目名称:portfolio,代码行数:27,代码来源:FrmForm.php

示例7: delete_duplicated_meta

 /**
  * delete entry meta so it won't be duplicated
  */
 private static function delete_duplicated_meta($action, $entry)
 {
     global $wpdb;
     $field_ids = array();
     foreach ($action->post_content as $name => $value) {
         // Don't try to delete meta for the display ID since this is never a field ID
         if ($name == 'display_id') {
             continue;
         }
         if (is_numeric($value)) {
             $field_ids[] = $value;
         } else {
             if (is_array($value) && isset($value['field_id']) && is_numeric($value['field_id'])) {
                 $field_ids[] = $value['field_id'];
             }
         }
         unset($name, $value);
     }
     if (!empty($field_ids)) {
         $where = array('item_id' => $entry->id, 'field_id' => $field_ids);
         FrmDb::get_where_clause_and_values($where);
         $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'frm_item_metas' . $where['where'], $where['values']));
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:27,代码来源:FrmProPost.php

示例8: widget

 function widget($args, $instance)
 {
     global $wpdb;
     $display = FrmProDisplay::getOne($instance['display_id'], false, true);
     $title = apply_filters('widget_title', empty($instance['title']) && $display ? $display->post_title : $instance['title']);
     $limit = empty($instance['limit']) ? ' LIMIT 100' : " LIMIT {$instance['limit']}";
     $post_id = !$display || empty($display->frm_post_id) ? $instance['post_id'] : $display->frm_post_id;
     $page_url = get_permalink($post_id);
     $order_by = '';
     $cat_field = false;
     if ($display && is_numeric($display->frm_form_id) && !empty($display->frm_form_id)) {
         //Set up order for Entries List Widget
         if (isset($display->frm_order_by) && !empty($display->frm_order_by)) {
             //Get only the first order field and order
             $order_field = reset($display->frm_order_by);
             $order = reset($display->frm_order);
             FrmAppHelper::esc_order_by($order);
             if ($order_field == 'rand') {
                 //If random is set, set the order to random
                 $order_by = ' RAND()';
             } else {
                 if (is_numeric($order_field)) {
                     //If ordering by a field
                     //Get all post IDs for this form
                     $posts = FrmDb::get_results($wpdb->prefix . 'frm_items', array('form_id' => $display->frm_form_id, 'post_id >' => 1, 'is_draft' => 0), 'id, post_id');
                     $linked_posts = array();
                     foreach ($posts as $post_meta) {
                         $linked_posts[$post_meta->post_id] = $post_meta->id;
                     }
                     //Get all field information
                     $o_field = FrmField::getOne($order_field);
                     $query = 'SELECT m.id FROM ' . $wpdb->prefix . 'frm_items m INNER JOIN ';
                     $where = array();
                     //create query with ordered values
                     //if field is some type of post field
                     if (isset($o_field->field_options['post_field']) && $o_field->field_options['post_field']) {
                         if ($o_field->field_options['post_field'] == 'post_custom' && !empty($linked_posts)) {
                             //if field is custom field
                             $where['pm.post_id'] = array_keys($linked_posts);
                             FrmDb::get_where_clause_and_values($where);
                             array_unshift($where['values'], $o_field->field_options['custom_field']);
                             $query .= $wpdb->postmeta . ' pm ON pm.post_id=m.post_id AND pm.meta_key=%s ' . $where['where'] . ' ORDER BY CASE when pm.meta_value IS NULL THEN 1 ELSE 0 END, pm.meta_value ' . $order;
                         } else {
                             if ($o_field->field_options['post_field'] != 'post_category' && !empty($linked_posts)) {
                                 //if field is a non-category post field
                                 $where['p.ID'] = array_keys($linked_posts);
                                 FrmDb::get_where_clause_and_values($where);
                                 $query .= $wpdb->posts . ' p ON p.ID=m.post_id ' . $where['where'] . ' ORDER BY CASE p.' . sanitize_title($o_field->field_options['post_field']) . ' WHEN "" THEN 1 ELSE 0 END, p.' . sanitize_title($o_field->field_options['post_field']) . ' ' . $order;
                             }
                         }
                     } else {
                         //if field is a normal, non-post field
                         $where['em.field_id'] = $o_field->id;
                         FrmDb::get_where_clause_and_values($where);
                         $query .= $wpdb->prefix . 'frm_item_metas em ON em.item_id=m.id ' . $where['where'] . ' ORDER BY CASE when em.meta_value IS NULL THEN 1 ELSE 0 END, em.meta_value' . ($o_field->type == 'number' ? ' +0 ' : '') . ' ' . $order;
                     }
                     //Get ordered values
                     if (!empty($where)) {
                         $metas = $wpdb->get_results($wpdb->prepare($query, $where['values']));
                     } else {
                         $metas = false;
                     }
                     unset($query, $where);
                     if (!empty($metas)) {
                         $order_by_array = array();
                         foreach ($metas as $meta) {
                             $order_by_array[] = $wpdb->prepare('it.id=%d DESC', $meta->id);
                         }
                         $order_by = implode(', ', $order_by_array);
                         unset($order_by_array);
                     } else {
                         $order_by .= 'it.created_at ' . $order;
                     }
                     unset($metas);
                 } else {
                     if (!empty($order_field)) {
                         //If ordering by created_at or updated_at
                         $order_by = 'it.' . sanitize_title($order_field) . ' ' . $order;
                     }
                 }
             }
             if (!empty($order_by)) {
                 $order_by = ' ORDER BY ' . $order_by;
             }
         }
         if (isset($instance['cat_list']) && (int) $instance['cat_list'] == 1 && is_numeric($instance['cat_id'])) {
             if ($cat_field = FrmField::getOne($instance['cat_id'])) {
                 $categories = maybe_unserialize($cat_field->options);
             }
         }
     }
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo '<ul id="frm_entry_list' . ($display ? $display->frm_form_id : '') . '">' . "\n";
     //if Listing entries by category
     if (isset($instance['cat_list']) && (int) $instance['cat_list'] == 1 && isset($categories) && is_array($categories)) {
         foreach ($categories as $cat_order => $cat) {
             if ($cat == '') {
//.........这里部分代码省略.........
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:101,代码来源:FrmListEntries.php

示例9: update_parent_id

 /**
  * After the sub entry and parent entry are created, we can update the parent id field
  * @since 2.0
  */
 public static function update_parent_id($entry_id, $form_id)
 {
     $form_fields = FrmProFormsHelper::has_field('form', $form_id, false);
     $section_fields = FrmProFormsHelper::has_repeat_field($form_id, false);
     if (!$form_fields && !$section_fields) {
         return;
     }
     $form_fields = array_merge($section_fields, $form_fields);
     $entry = FrmEntry::getOne($entry_id, true);
     if (!$entry || $entry->form_id != $form_id) {
         return;
     }
     $sub_ids = array();
     foreach ($form_fields as $field) {
         if (!isset($entry->metas[$field->id])) {
             continue;
         }
         $ids = maybe_unserialize($entry->metas[$field->id]);
         if (!empty($ids)) {
             $sub_ids = array_merge($ids, $sub_ids);
         }
         unset($field);
     }
     if (!empty($sub_ids)) {
         $where = array('id' => $sub_ids);
         FrmDb::get_where_clause_and_values($where);
         array_unshift($where['values'], $entry_id);
         global $wpdb;
         $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'frm_items SET parent_item_id = %d' . $where['where'], $where['values']));
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:35,代码来源:FrmProEntry.php


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