本文整理汇总了PHP中FrmDb::get_var方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmDb::get_var方法的具体用法?PHP FrmDb::get_var怎么用?PHP FrmDb::get_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmDb
的用法示例。
在下文中一共展示了FrmDb::get_var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_single_field
/**
* @since 2.0.11
*/
public static function update_single_field($atts)
{
if (empty($atts['entry_id'])) {
return;
}
$field = $atts['field_id'];
FrmField::maybe_get_field($field);
if (!$field) {
return;
}
if (isset($field->field_options['post_field']) && !empty($field->field_options['post_field'])) {
$post_id = FrmDb::get_var('frm_items', array('id' => $atts['entry_id']), 'post_id');
} else {
$post_id = false;
}
global $wpdb;
if (!$post_id) {
$updated = FrmEntryMeta::update_entry_meta($atts['entry_id'], $field->id, null, $atts['value']);
if (!$updated) {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE item_id = %d and field_id = %d", $atts['entry_id'], $field->id));
$updated = FrmEntryMeta::add_entry_meta($atts['entry_id'], $field->id, '', $atts['value']);
}
wp_cache_delete($atts['entry_id'], 'frm_entry');
} else {
switch ($field->field_options['post_field']) {
case 'post_custom':
$updated = update_post_meta($post_id, $field->field_options['custom_field'], maybe_serialize($atts['value']));
break;
case 'post_category':
$taxonomy = !FrmField::is_option_empty($field, 'taxonomy') ? $field->field_options['taxonomy'] : 'category';
$updated = wp_set_post_terms($post_id, $atts['value'], $taxonomy);
break;
default:
$post = get_post($post_id, ARRAY_A);
$post[$field->field_options['post_field']] = maybe_serialize($atts['value']);
$updated = wp_insert_post($post);
break;
}
}
if ($updated) {
// set updated_at time
$wpdb->update($wpdb->prefix . 'frm_items', array('updated_at' => current_time('mysql', 1), 'updated_by' => get_current_user_id()), array('id' => $atts['entry_id']));
}
$atts['field_id'] = $field->id;
$atts['field'] = $field;
do_action('frm_after_update_field', $atts);
return $updated;
}
示例2: 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);
}
}
}
示例3: get_shortcode_select
//.........这里部分代码省略.........
<option class="frm_subopt" value="<?php
echo esc_attr($field->field_key);
?>
size=thumbnail"><?php
_e('Thumbnail', 'formidable');
?>
</option>
<option class="frm_subopt" value="<?php
echo esc_attr($field->field_key);
?>
size=medium"><?php
_e('Medium', 'formidable');
?>
</option>
<option class="frm_subopt" value="<?php
echo esc_attr($field->field_key);
?>
size=large"><?php
_e('Large', 'formidable');
?>
</option>
<option class="frm_subopt" value="<?php
echo esc_attr($field->field_key);
?>
size=full"><?php
_e('Full Size', 'formidable');
?>
</option>
<?php
} else {
if ($field->type == 'data') {
//get all fields from linked form
if (isset($field->field_options['form_select']) && is_numeric($field->field_options['form_select'])) {
$linked_form = FrmDb::get_var('frm_fields', array('id' => $field->field_options['form_select']), 'form_id');
if (!in_array($linked_form, $linked_forms)) {
$linked_forms[] = $linked_form;
$linked_fields = FrmField::getAll(array('fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => (int) $linked_form));
foreach ($linked_fields as $linked_field) {
?>
<option class="frm_subopt" value="<?php
echo esc_attr($field->id . ' show=' . $linked_field->id);
?>
"><?php
echo esc_html(FrmAppHelper::truncate($linked_field->name, 60));
?>
(<?php
_e('ID', 'formidable');
?>
)</option>
<option class="frm_subopt" value="<?php
echo esc_attr($field->field_key . ' show=' . $linked_field->field_key);
?>
"><?php
echo esc_html(FrmAppHelper::truncate($linked_field->name, 60));
?>
(<?php
_e('Key', 'formidable');
?>
)</option>
<?php
}
}
}
}
}
}
示例4: get_auto_custom_display
/**
* Check for a qualified view.
* Qualified: 1. set to show calendar or dynamic
* 2. published
* 3. form has posts/entry is linked to a post
*/
public static function get_auto_custom_display($args)
{
$defaults = array('post_id' => false, 'form_id' => false, 'entry_id' => false);
$args = wp_parse_args($args, $defaults);
global $wpdb;
if ($args['form_id']) {
$display_ids = self::get_display_ids_by_form($args['form_id']);
if (!$display_ids) {
return false;
}
if (!$args['post_id'] && !$args['entry_id']) {
//does form have posts?
$args['entry_id'] = FrmDb::get_var('frm_items', array('form_id' => $args['form_id']), 'post_id');
}
}
if ($args['post_id'] && !$args['entry_id']) {
//is post linked to an entry?
$args['entry_id'] = FrmDb::get_var($wpdb->prefix . 'frm_items', array('post_id' => $args['post_id']));
//is post selected for auto-insertion?
if (!$args['entry_id']) {
$query = array('meta_key' => 'frm_post_id', 'meta_value' => $args['post_id']);
if (isset($display_ids)) {
$query['post_ID'] = $display_ids;
}
$display_ids = FrmDb::get_col($wpdb->postmeta, $query, 'post_ID');
if (!$display_ids) {
return false;
}
}
}
//this post does not have an auto display
if (!$args['entry_id']) {
return false;
}
$query = array('pm.meta_key' => 'frm_show_count', 'post_type' => 'frm_display', 'pm.meta_value' => array('dynamic', 'calendar', 'one'), 'p.post_status' => 'publish');
if (isset($display_ids)) {
$query['p.ID'] = $display_ids;
}
$display = FrmDb::get_row($wpdb->posts . ' p LEFT JOIN ' . $wpdb->postmeta . ' pm ON (p.ID = pm.post_ID)', $query, 'p.*', array('order_by' => 'p.ID ASC'));
return $display;
}
示例5: entry_update_field
public static function entry_update_field($atts)
{
global $frm_vars, $post, $frm_update_link, $wpdb;
$atts = shortcode_atts(array('id' => isset($frm_vars['editing_entry']) ? $frm_vars['editing_entry'] : false, 'field_id' => false, 'form_id' => false, 'label' => __('Update', 'formidable'), 'class' => '', 'value' => '', 'message' => '', 'title' => '', 'allow' => ''), $atts);
$entry_id = $atts['id'] && is_numeric($atts['id']) ? absint($atts['id']) : FrmAppHelper::get_param('entry', false, 'get', 'absint');
if (!$entry_id || empty($entry_id)) {
return;
}
if (!$atts['form_id']) {
$atts['form_id'] = (int) FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $entry_id), 'form_id');
}
if ($atts['allow'] != 'everyone' && !FrmProEntriesHelper::user_can_edit($entry_id, $atts['form_id'])) {
return;
}
$field = FrmField::getOne($atts['field_id']);
if (!$field) {
return;
}
if (!is_numeric($atts['field_id'])) {
$atts['field_id'] = $field->id;
}
//check if current value is equal to new value
$current_val = FrmProEntryMetaHelper::get_post_or_meta_value($entry_id, $field);
if ($current_val == $atts['value']) {
return;
}
if (!$frm_update_link) {
$frm_update_link = array();
}
$num = isset($frm_update_link[$entry_id . '-' . $atts['field_id']]) ? $frm_update_link[$entry_id . '-' . $atts['field_id']] : 0;
$num = (int) $num + 1;
$frm_update_link[$entry_id . '-' . $atts['field_id']] = $num;
if (empty($atts['title'])) {
$atts['title'] = $atts['label'];
}
$link = '<a href="#" onclick="frmUpdateField(' . $entry_id . ',' . $atts['field_id'] . ',\'' . $atts['value'] . '\',\'' . htmlspecialchars(str_replace("'", '\\"', $atts['message'])) . '\',' . $num . ');return false;" id="frm_update_field_' . $entry_id . '_' . $atts['field_id'] . '_' . $num . '" class="frm_update_field_link ' . $atts['class'] . '" title="' . esc_attr($atts['title']) . '">' . $atts['label'] . '</a>';
return $link;
}
示例6: array
/**
* @param int $id
* @return string form key
*/
public static function &getKeyById($id)
{
$id = (int) $id;
$cache = FrmAppHelper::check_cache($id, 'frm_form');
if ($cache) {
return $cache->form_key;
}
$key = FrmDb::get_var('frm_forms', array('id' => $id), 'form_key');
return $key;
}
示例7: array
/**
* @param string $id
*/
public static function &exists($id)
{
global $wpdb;
if (FrmAppHelper::check_cache($id, 'frm_entry')) {
$exists = true;
return $exists;
}
if (is_numeric($id)) {
$where = array('id' => $id);
} else {
$where = array('item_key' => $id);
}
$id = FrmDb::get_var($wpdb->prefix . 'frm_items', $where);
$exists = $id && $id > 0 ? true : false;
return $exists;
}
示例8: is_ajax_on
public static function is_ajax_on($form)
{
$ajax = isset($form->options['ajax_submit']) ? $form->options['ajax_submit'] : 0;
if ($ajax) {
$no_ajax_fields = array('file');
$where = array(array('or' => 1, 'form.id' => $form->id, 'form.parent_form_id' => $form->id), 'type' => $no_ajax_fields);
if (isset($_POST['frm_page_order_' . $form->id])) {
$where['field_order <'] = absint($_POST['frm_page_order_' . $form->id]) - 1;
}
global $wpdb;
$no_ajax = FrmDb::get_var($wpdb->prefix . 'frm_fields field INNER JOIN ' . $wpdb->prefix . 'frm_forms form ON field.form_id = form.id', $where, 'field.id');
$ajax = $no_ajax ? false : true;
}
return $ajax;
}
示例9: get_id_by_key
/**
* @param string $key
* @return int field id
*/
public static function get_id_by_key($key)
{
$id = FrmDb::get_var('frm_fields', array('field_key' => sanitize_title($key)));
return $id;
}
示例10: array
$linked_forms[] = array();
foreach ($fields as $f) {
if (FrmField::is_repeating_field($f)) {
$repeat_field = $f->id;
}
if (FrmField::is_no_save_field($f->type)) {
continue;
}
if ($f->type == 'data' && (!isset($f->field_options['data_type']) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '')) {
continue;
}
FrmAppHelper::insert_opt_html(array('id' => $f->id, 'key' => $f->field_key, 'name' => $f->name, 'type' => $f->type));
if ($f->type == 'data') {
//get all fields from linked form
if (isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select'])) {
$linked_form = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('id' => $f->field_options['form_select']), 'form_id');
if (!in_array($linked_form, $linked_forms)) {
$linked_forms[] = $linked_form;
$linked_fields = FrmField::getAll(array('fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form));
$ldfe = '';
if ($linked_fields) {
foreach ($linked_fields as $linked_field) {
FrmAppHelper::insert_opt_html(array('id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type));
$ldfe = $linked_field->id;
unset($linked_field);
}
}
}
}
$dfe = $f->id;
}
示例11: get_dfe_id
public static function get_dfe_id($value, $field, $ids = array())
{
global $wpdb;
if (!$field || FrmProField::is_list_field($field)) {
return $value;
}
if (!empty($ids) && is_numeric($value) && isset($ids[$value])) {
// the entry was just imported, so we have the id
return $ids[$value];
}
if (!is_array($value)) {
$new_id = FrmDb::get_var('frm_item_metas', array('field_id' => $field->field_options['form_select'], 'meta_value' => $value), 'item_id');
if ($new_id && is_numeric($new_id)) {
return $new_id;
}
unset($new_id);
}
if (!is_array($value) && strpos($value, ',')) {
$checked = maybe_unserialize($value);
if (!is_array($checked)) {
$checked = explode(',', $checked);
}
} else {
$checked = $value;
}
if (!$checked || !is_array($checked)) {
return $value;
}
$value = array_map('trim', $checked);
foreach ($value as $dfe_k => $dfe_id) {
$query = array('field_id' => $field->field_options['form_select'], 'meta_value' => $dfe_id);
$new_id = FrmDb::get_var('frm_item_metas', $query, 'item_id');
if ($new_id) {
$value[$dfe_k] = $new_id;
}
unset($new_id);
}
unset($checked);
return $value;
}
示例12: get_default_field_opts
public static function get_default_field_opts($type, $field, $limit = false)
{
$field_options = array('size' => '', 'max' => '', 'label' => '', 'blank' => '', 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', 'custom_html' => '');
if ($limit) {
return $field_options;
}
global $wpdb;
$form_id = is_numeric($field) ? $field : $field->form_id;
$key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_fields', 'field_key') : $field->field_key;
$field_count = FrmDb::get_var('frm_fields', array('form_id' => $form_id), 'field_order', array('order_by' => 'field_order DESC'));
$frm_settings = FrmAppHelper::get_settings();
return array('name' => __('Untitled', 'formidable'), 'description' => '', 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', 'field_order' => $field_count + 1, 'required' => false, 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, 'invalid' => __('This field is invalid', 'formidable'), 'form_id' => $form_id, 'field_options' => $field_options);
}
示例13: 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);
}
}
示例14: graph_shortcode
public static function graph_shortcode($atts)
{
$defaults = array('id' => false, 'id2' => false, 'id3' => false, 'id4' => false, 'ids' => array(), 'colors' => '', 'grid_color' => '#CCC', 'is3d' => false, 'height' => 400, 'width' => 400, 'truncate_label' => 7, 'bg_color' => '#FFFFFF', 'truncate' => 40, 'response_count' => 10, 'user_id' => false, 'entry_id' => false, 'title' => '', 'type' => 'default', 'x_axis' => false, 'data_type' => 'count', 'limit' => '', 'show_key' => false, 'min' => '', 'max' => '', 'y_title' => '', 'x_title' => '', 'include_zero' => false, 'field' => false, 'title_size' => '', 'title_font' => '', 'tooltip_label' => '', 'start_date' => '', 'end_date' => '', 'x_start' => '', 'x_end' => '', 'group_by' => '', 'x_order' => 'default', 'atts' => false);
// TODO: Remove limit from docs, add x_order='desc' and x_order='field_options'
// Remove id from docs. Just use ids to simplify.
// Remove either x start or start_date from docs
// Remove either x_end or end_date from docs
// Make sure x_order is set up to work with abc
// If no id, stop now
if (!$atts || !$atts['id']) {
echo __('You must include a field id or key in your graph shortcode.', 'formidable');
return;
}
if (isset($atts['type']) && $atts['type'] == 'geo') {
$defaults['truncate_label'] = 100;
$defaults['width'] = 600;
}
if (isset($atts['include_js'])) {
unset($atts['include_js']);
}
// Set up array for filtering fields
// TODO: Ask about simpler way
$temp_atts = $atts;
foreach ($defaults as $unset => $val) {
unset($temp_atts[$unset], $unset, $val);
}
foreach ($temp_atts as $unset => $val) {
unset($atts[$unset]);
$atts['atts'][$unset] = $val;
unset($unset, $val);
}
// User's values should override default values
$atts = array_merge($defaults, $atts);
global $wpdb;
// Reverse compatibility for id2, id3, and id4
if (!$atts['ids'] && ($atts['id2'] || $atts['id3'] || $atts['id4'])) {
_deprecated_argument(__FUNCTION__, '1.07.05', __('id2, id3, and id4 are deprecated. Please use ids instead.', 'formidable'));
$atts['ids'] = array($atts['id2'], $atts['id3'], $atts['id4']);
$atts['ids'] = implode(',', $atts['ids']);
unset($atts['id2'], $atts['id3'], $atts['id4']);
}
//x_start and start_date do the same thing
// Reverse compatibility for x_start
if ($atts['start_date'] || $atts['x_start']) {
if ($atts['x_start']) {
$atts['start_date'] = $atts['x_start'];
unset($atts['x_start']);
}
$atts['start_date'] = FrmAppHelper::replace_quotes($atts['start_date']);
}
//x_end and end_date do the same thing
// Reverse compatibility for x_end
if ($atts['end_date'] || $atts['x_end']) {
if ($atts['x_end']) {
$atts['end_date'] = $atts['x_end'];
unset($atts['x_end']);
}
$atts['end_date'] = FrmAppHelper::replace_quotes($atts['end_date']);
}
// Reverse compatibility for x_order=0
if (!$atts['x_order']) {
$atts['x_order'] = 'field_opts';
}
// If limit is set, get only the top results
if ($atts['limit']) {
$atts['x_order'] = 'desc';
}
$atts['user_id'] = FrmAppHelper::get_user_id_param($atts['user_id']);
if ($atts['entry_id']) {
$atts['entry_id'] = explode(',', $atts['entry_id']);
//make sure all values are numeric
//TODO: Make this work with entry keys
$atts['entry_id'] = array_filter($atts['entry_id'], 'is_numeric');
if (empty($atts['entry_id'])) {
// don't continue if there are no entry ids
return;
}
$atts['entry_id'] = implode(',', $atts['entry_id']);
}
// Switch to entry_ids for easier reference
$atts['entry_ids'] = $atts['entry_id'];
unset($atts['entry_id']);
//Convert $tooltip_label to array
if ($atts['tooltip_label']) {
$atts['tooltip_label'] = explode(',', $atts['tooltip_label']);
}
// This will only be an object when coming from show()
if (is_object($atts['field'])) {
$fields = array($atts['field']);
// If creating multiple graphs with one shortcode
} else {
$atts['id'] = explode(',', $atts['id']);
foreach ($atts['id'] as $key => $id) {
//If using field keys, retrieve the field IDs
if (!is_numeric($id)) {
$atts['id'][$key] = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('field_key' => $id));
}
unset($key, $id);
}
//make sure all field IDs are numeric - TODO: ask Steph if this is redundant
//.........这里部分代码省略.........
示例15: has_field
public static function has_field($type, $form_id, $single = true)
{
global $wpdb;
if ($single) {
$included = FrmDb::get_var('frm_fields', array('form_id' => $form_id, 'type' => $type));
if ($included) {
$included = FrmField::getOne($included);
}
} else {
$included = FrmField::get_all_types_in_form($form_id, $type);
}
return $included;
}