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


PHP pods_data函数代码示例

本文整理汇总了PHP中pods_data函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_data函数的具体用法?PHP pods_data怎么用?PHP pods_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: pods_query

/**
 * Standardize queries and error reporting. It replaces @wp_ with $wpdb->prefix.
 *
 * @see PodsData::query
 *
 * @param string $sql SQL Query
 * @param string $error (optional) The failure message
 * @param string $results_error (optional) Throw an error if a records are found
 * @param string $no_results_error (optional) Throw an error if no records are found
 *
 * @return array|bool|mixed|null|void
 * @since 2.0
 */
function pods_query($sql, $error = 'Database Error', $results_error = null, $no_results_error = null)
{
    $podsdata = pods_data();
    $sql = apply_filters('pods_query_sql', $sql, $error, $results_error, $no_results_error);
    $sql = $podsdata->get_sql($sql);
    if (is_array($error)) {
        if (!is_array($sql)) {
            $sql = array($sql, $error);
        }
        $error = 'Database Error';
    }
    if (1 == pods_v('pods_debug_sql_all', 'get', 0) && is_user_logged_in() && pods_is_admin(array('pods'))) {
        $debug_sql = $sql;
        echo '<textarea cols="100" rows="24">';
        if (is_array($debug_sql)) {
            $debug_sql = print_r($debug_sql, true);
        }
        echo esc_textarea($debug_sql);
        echo '</textarea>';
    }
    return $podsdata->query($sql, $error, $results_error, $no_results_error);
}
开发者ID:pods-framework,项目名称:pods,代码行数:35,代码来源:general.php

示例2: save_pod_item


//.........这里部分代码省略.........
                 unset($fields_to_send[$field]);
             }
             $fields_to_send[$field] = $field_data;
         }
         $params->id = $this->save_wp_object($object_type, $object_data, $object_meta, false, true, $fields_to_send);
         if (!empty($params->id) && 'settings' == $object_type) {
             $params->id = $pod['id'];
         }
     } else {
         if (!in_array($pod['type'], array('taxonomy', 'pod', 'table', ''))) {
             $params->id = $this->save_wp_object($object_type, $object_data, array(), false, true);
         } elseif ('taxonomy' == $pod['type']) {
             $term = pods_v($object_fields['name']['name'], $object_data, '', null, true);
             if (!isset($term_data)) {
                 $term_data = array();
             }
             if (empty($params->id) || !empty($term_data)) {
                 $taxonomy = $pod['name'];
                 if (!empty($pod['object'])) {
                     $taxonomy = $pod['object'];
                 }
                 $params->id = $this->save_term($params->id, $term, $taxonomy, $term_data, true);
             }
         }
         if ('table' == $pod['storage']) {
             // Every row should have an id set here, otherwise Pods with nothing
             // but relationship fields won't get properly ID'd
             if (empty($params->id)) {
                 $params->id = 0;
             }
             $table_data = array('id' => $params->id) + $table_data;
             array_unshift($table_formats, '%d');
             if (!empty($table_data)) {
                 $sql = pods_data()->insert_on_duplicate("@wp_pods_{$params->pod}", $table_data, $table_formats);
                 $id = pods_query($sql, 'Cannot add/save table row');
                 if (empty($params->id)) {
                     $params->id = $id;
                 }
             }
         }
     }
     $params->id = (int) $params->id;
     // Save terms for taxonomies associated to a post type
     if (0 < $params->id && 'post_type' == $pod['type'] && !empty($post_term_data)) {
         foreach ($post_term_data as $post_taxonomy => $post_terms) {
             $post_terms = (array) $post_terms;
             foreach ($post_terms as $k => $v) {
                 if (!preg_match('/[^0-9]/', $v)) {
                     $v = (int) $v;
                 }
                 $post_terms[$k] = $v;
             }
             wp_set_object_terms($params->id, $post_terms, $post_taxonomy);
         }
     }
     $no_conflict = pods_no_conflict_check($pod['type']);
     if (!$no_conflict) {
         pods_no_conflict_on($pod['type']);
     }
     // Save relationship / file data
     if (!empty($rel_fields)) {
         foreach ($rel_fields as $type => $data) {
             // Only handle tableless fields
             if (!in_array($type, $tableless_field_types)) {
                 continue;
             }
开发者ID:satokora,项目名称:IT354Project,代码行数:67,代码来源:PodsAPI.php

示例3: __construct

 /**
  * Generate UI for Data Management
  *
  * @param mixed $options Object, Array, or String containing Pod or Options to be used
  * @param bool $deprecated Set to true to support old options array from Pods UI plugin
  *
  * @return \PodsUI
  *
  * @license http://www.gnu.org/licenses/gpl-2.0.html
  * @since 2.0
  */
 public function __construct($options, $deprecated = false)
 {
     $this->_nonce = pods_v('_wpnonce', 'request');
     $object = null;
     if (is_object($options)) {
         $object = $options;
         $options = array();
         if (isset($object->ui)) {
             $options = (array) $object->ui;
             unset($object->ui);
         }
         if (is_object($object) && ('Pods' == get_class($object) || 'Pod' == get_class($object))) {
             $this->pod =& $object;
         }
     }
     if (!is_array($options)) {
         // @todo need to come back to this and allow for multi-dimensional strings
         // like: option=value&option2=value2&option3=key[val],key2[val2]&option4=this,that,another
         if (false !== strpos($options, '=') || false !== strpos($options, '&')) {
             parse_str($options, $options);
         } else {
             $options = array('pod' => $options);
         }
     }
     if (!is_object($object) && isset($options['pod'])) {
         if (is_object($options['pod'])) {
             $this->pod = $options['pod'];
         } elseif (isset($options['id'])) {
             $this->pod = pods($options['pod'], $options['id']);
         } else {
             $this->pod = pods($options['pod']);
         }
         unset($options['pod']);
     } elseif (is_object($object)) {
         $this->pod = $object;
     }
     if (false !== $deprecated || is_object($this->pod) && 'Pod' == get_class($this->pod)) {
         $options = $this->setup_deprecated($options);
     }
     if (is_object($this->pod) && 'Pod' == get_class($this->pod) && is_object($this->pod->_data)) {
         $this->pods_data =& $this->pod->_data;
     } elseif (is_object($this->pod) && 'Pods' == get_class($this->pod) && is_object($this->pod->data)) {
         $this->pods_data =& $this->pod->data;
     } elseif (is_object($this->pod)) {
         $this->pods_data = pods_data($this->pod->pod);
     } elseif (!is_object($this->pod)) {
         $this->pods_data = pods_data($this->pod);
     }
     $options = $this->do_hook('pre_init', $options);
     $this->setup($options);
     if (is_object($this->pods_data) && is_object($this->pod) && 0 < $this->id) {
         if ($this->id != $this->pods_data->id) {
             $this->row = $this->pods_data->fetch($this->id);
         } else {
             $this->row = $this->pods_data->row;
         }
     }
     if ((!is_object($this->pod) || 'Pods' != get_class($this->pod)) && false === $this->sql['table'] && false === $this->data) {
         echo $this->error(__('<strong>Error:</strong> Pods UI needs a Pods object or a Table definition to run from, see the User Guide for more information.', 'pods'));
         return false;
     }
     $this->go();
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:74,代码来源:PodsUI.php

示例4: get_object_data

 /**
  * Get data from relationship objects
  *
  * @param array $object_params Object data parameters
  *
  * @return array|bool Object data
  */
 public function get_object_data($object_params = null)
 {
     global $wpdb, $polylang, $sitepress, $icl_adjust_id_url_filter_off;
     $current_language = false;
     // WPML support
     if (is_object($sitepress) && !$icl_adjust_id_url_filter_off) {
         $current_language = pods_sanitize(ICL_LANGUAGE_CODE);
     } elseif (function_exists('pll_current_language')) {
         $current_language = pll_current_language('slug');
     }
     $object_params = array_merge(array('name' => '', 'value' => '', 'options' => array(), 'pod' => '', 'id' => '', 'context' => '', 'data_params' => array('query' => ''), 'page' => 1, 'limit' => 0), $object_params);
     $name = $object_params['name'];
     $value = $object_params['value'];
     $options = $object_params['options'] = (array) $object_params['options'];
     $pod = $object_params['pod'];
     $id = $object_params['id'];
     $context = $object_params['context'];
     $data_params = $object_params['data_params'] = (array) $object_params['data_params'];
     $page = min(1, (int) $object_params['page']);
     $limit = (int) $object_params['limit'];
     if (isset($options['options'])) {
         $options = array_merge($options, $options['options']);
         unset($options['options']);
     }
     $data = apply_filters('pods_field_pick_object_data', null, $name, $value, $options, $pod, $id, $object_params);
     $items = array();
     if (!isset($options[self::$type . '_object'])) {
         $data = pods_var_raw('data', $options, array(), null, true);
     }
     $simple = false;
     if (null === $data) {
         $data = array();
         if ('custom-simple' == $options[self::$type . '_object']) {
             $custom = pods_var_raw(self::$type . '_custom', $options, '');
             $custom = apply_filters('pods_form_ui_field_pick_custom_values', $custom, $name, $value, $options, $pod, $id, $object_params);
             if (!empty($custom)) {
                 if (!is_array($custom)) {
                     $data = array();
                     $custom = explode("\n", trim($custom));
                     foreach ($custom as $custom_value) {
                         $custom_label = explode('|', $custom_value);
                         if (empty($custom_label)) {
                             continue;
                         }
                         if (1 == count($custom_label)) {
                             $custom_label = $custom_value;
                         } else {
                             $custom_value = $custom_label[0];
                             $custom_label = $custom_label[1];
                         }
                         $custom_value = trim((string) $custom_value);
                         $custom_label = trim((string) $custom_label);
                         $data[$custom_value] = $custom_label;
                     }
                 } else {
                     $data = $custom;
                 }
                 $simple = true;
             }
         } elseif (isset(self::$related_objects[$options[self::$type . '_object']]) && isset(self::$related_objects[$options[self::$type . '_object']]['data']) && !empty(self::$related_objects[$options[self::$type . '_object']]['data'])) {
             $data = self::$related_objects[$options[self::$type . '_object']]['data'];
             $simple = true;
         } elseif (isset(self::$related_objects[$options[self::$type . '_object']]) && isset(self::$related_objects[$options[self::$type . '_object']]['data_callback']) && is_callable(self::$related_objects[$options[self::$type . '_object']]['data_callback'])) {
             $data = call_user_func_array(self::$related_objects[$options[self::$type . '_object']]['data_callback'], array($name, $value, $options, $pod, $id));
             $simple = true;
             // Cache data from callback
             if (!empty($data)) {
                 self::$related_objects[$options[self::$type . '_object']]['data'] = $data;
             }
         } elseif ('simple_value' != $context) {
             $pick_val = pods_var(self::$type . '_val', $options);
             if ('table' == pods_var(self::$type . '_object', $options)) {
                 $pick_val = pods_var(self::$type . '_table', $options, $pick_val, null, true);
             }
             if ('__current__' == $pick_val) {
                 if (is_object($pod)) {
                     $pick_val = $pod->pod;
                 } elseif (is_array($pod)) {
                     $pick_val = $pod['name'];
                 } elseif (0 < strlen($pod)) {
                     $pick_val = $pod;
                 }
             }
             $options['table_info'] = pods_api()->get_table_info(pods_var(self::$type . '_object', $options), $pick_val, null, null, $options);
             $search_data = pods_data();
             $search_data->table($options['table_info']);
             if (isset($options['table_info']['pod']) && !empty($options['table_info']['pod']) && isset($options['table_info']['pod']['name'])) {
                 $search_data->pod = $options['table_info']['pod']['name'];
                 $search_data->fields = $options['table_info']['pod']['fields'];
             }
             $params = array('select' => "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`", 'table' => $search_data->table, 'where' => pods_var_raw(self::$type . '_where', $options, (array) $options['table_info']['where_default'], null, true), 'orderby' => pods_var_raw(self::$type . '_orderby', $options, null, null, true), 'groupby' => pods_var_raw(self::$type . '_groupby', $options, null, null, true), 'pagination' => false, 'search' => false);
             if (in_array($options[self::$type . '_object'], array('site', 'network'))) {
                 $params['select'] .= ', `t`.`path`';
//.........这里部分代码省略.........
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:101,代码来源:pick.php

示例5: fetch


//.........这里部分代码省略.........
                 }
             } elseif ('id' == $mode) {
                 $this->row = get_term($id, $taxonomy, ARRAY_A);
             } else {
                 $this->row = get_term_by('slug', $id, $taxonomy, ARRAY_A);
             }
             if (is_wp_error($this->row) || empty($this->row)) {
                 $this->row = false;
             } else {
                 $current_row_id = $this->row['term_id'];
             }
             $get_table_data = true;
         } elseif ('user' == $this->pod_data['type']) {
             if ('id' == $mode) {
                 $this->row = get_userdata($id);
             } else {
                 $this->row = get_user_by('slug', $id);
             }
             if (is_wp_error($this->row) || empty($this->row)) {
                 $this->row = false;
             } else {
                 // Get other vars
                 $roles = $this->row->roles;
                 $caps = $this->row->caps;
                 $allcaps = $this->row->allcaps;
                 $this->row = get_object_vars($this->row->data);
                 // Set other vars
                 $this->row['roles'] = $roles;
                 $this->row['caps'] = $caps;
                 $this->row['allcaps'] = $allcaps;
                 unset($this->row['user_pass']);
                 $current_row_id = $this->row['ID'];
             }
             $get_table_data = true;
         } elseif ('comment' == $this->pod_data['type']) {
             $this->row = get_comment($id, ARRAY_A);
             // No slug handling here
             if (is_wp_error($this->row) || empty($this->row)) {
                 $this->row = false;
             } else {
                 $current_row_id = $this->row['comment_ID'];
             }
             $get_table_data = true;
         } elseif ('settings' == $this->pod_data['type']) {
             $this->row = array();
             if (empty($this->fields)) {
                 $this->row = false;
             } else {
                 foreach ($this->fields as $field) {
                     if (!in_array($field['type'], $tableless_field_types)) {
                         $this->row[$field['name']] = get_option($this->pod_data['name'] . '_' . $field['name'], null);
                     }
                 }
                 // Force ID
                 $this->id = $this->pod_data['id'];
                 $this->row['option_id'] = $this->id;
             }
         } else {
             $params = array('table' => $this->table, 'where' => "`t`.`{$this->field_id}` = " . (int) $id, 'orderby' => "`t`.`{$this->field_id}` DESC", 'page' => 1, 'limit' => 1, 'search' => false);
             if ('slug' == $mode && !empty($this->field_slug)) {
                 $id = pods_sanitize($id);
                 $params['where'] = "`t`.`{$this->field_slug}` = '{$id}'";
             }
             $this->row = pods_data()->select($params);
             if (empty($this->row)) {
                 $this->row = false;
             } else {
                 $current_row = (array) $this->row;
                 $this->row = get_object_vars((object) @current($current_row));
             }
         }
         if (!$explicit_set && is_array($this->row) && !empty($this->row) && !empty($old_row)) {
             $this->row = array_merge($old_row, $this->row);
         }
         if ('table' == $this->pod_data['storage'] && false !== $get_table_data && is_numeric($current_row_id)) {
             $params = array('table' => $wpdb->prefix . "pods_", 'where' => "`t`.`id` = {$current_row_id}", 'orderby' => "`t`.`id` DESC", 'page' => 1, 'limit' => 1, 'search' => false, 'strict' => true);
             if (empty($this->pod_data['object'])) {
                 $params['table'] .= $this->pod_data['name'];
             } else {
                 $params['table'] .= $this->pod_data['object'];
             }
             $row = pods_data()->select($params);
             if (!empty($row)) {
                 $current_row = (array) $row;
                 $row = get_object_vars((object) @current($current_row));
                 if (is_array($this->row) && !empty($this->row)) {
                     $this->row = array_merge($row, $this->row);
                 } else {
                     $this->row = $row;
                 }
             }
         }
         // @todo Figure out why taking out this in_array() causes cached data issues in User edit screen
         if (!empty($this->pod) && in_array($this->pod_data['type'], array('pod', 'table'))) {
             pods_cache_set($id, $this->row, 'pods_items_' . $this->pod, 0);
         }
     }
     $this->row = $this->do_hook('fetch', $this->row, $id, $this->row_number);
     return $this->row;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:101,代码来源:PodsData.php

示例6: field


//.........这里部分代码省略.........
                             if (!empty($where)) {
                                 $where = array(implode(' OR ', $where));
                             }
                             if (!empty($table['where'])) {
                                 $where = array_merge($where, array_values((array) $table['where']));
                             }
                         }
                         /**
                          * @var $related_obj Pods
                          */
                         $related_obj = false;
                         if ('pod' == $object_type) {
                             $related_obj = pods($object, null, false);
                         } elseif (isset($table['pod']) && !empty($table['pod'])) {
                             $related_obj = pods($table['pod']['name'], null, false);
                         }
                         if (!empty($table['table']) || !empty($related_obj)) {
                             $sql = array('select' => '*, `t`.`' . $table['field_id'] . '` AS `pod_item_id`', 'table' => $table['table'], 'join' => $join, 'where' => $where, 'orderby' => $params->orderby, 'pagination' => false, 'search' => false, 'limit' => -1);
                             // Output types
                             if (in_array($params->output, array('ids', 'objects', 'pods'))) {
                                 $sql['select'] = '`t`.`' . $table['field_id'] . '` AS `pod_item_id`';
                             } elseif ('names' == $params->output && !empty($table['field_index'])) {
                                 $sql['select'] = '`t`.`' . $table['field_index'] . '` AS `pod_item_index`, `t`.`' . $table['field_id'] . '` AS `pod_item_id`';
                             }
                             if (is_array($params->params) && !empty($params->params)) {
                                 $where = $sql['where'];
                                 $sql = array_merge($sql, $params->params);
                                 if (isset($params->params['where'])) {
                                     $sql['where'] = array_merge((array) $where, (array) $params->params['where']);
                                 }
                             }
                             if (empty($related_obj)) {
                                 if (!is_object($this->alt_data)) {
                                     $this->alt_data = pods_data(null, 0, true, true);
                                 }
                                 $item_data = $this->alt_data->select($sql);
                             } else {
                                 $item_data = $related_obj->find($sql)->data();
                             }
                             $items = array();
                             if (!empty($item_data)) {
                                 foreach ($item_data as $item) {
                                     if (is_array($item)) {
                                         $item = (object) $item;
                                     }
                                     if (empty($item->pod_item_id)) {
                                         continue;
                                     }
                                     // Bypass pass field
                                     if (isset($item->user_pass)) {
                                         unset($item->user_pass);
                                     }
                                     // Get Item ID
                                     $item_id = $item->pod_item_id;
                                     // Cleanup
                                     unset($item->pod_item_id);
                                     // Output types
                                     if ('ids' == $params->output) {
                                         $item = (int) $item_id;
                                     } elseif ('names' == $params->output && !empty($table['field_index'])) {
                                         $item = $item->pod_item_index;
                                     } elseif ('objects' == $params->output) {
                                         if (in_array($object_type, array('post_type', 'media'))) {
                                             $item = get_post($item_id);
                                         } elseif ('taxonomy' == $object_type) {
                                             $item = get_term($item_id, $object);
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:67,代码来源:Pods.php

示例7: fetch


//.........这里部分代码省略.........
                 $args = array('post_type' => $post_type, 'name' => $id, 'numberposts' => 5);
                 $find = get_posts($args);
                 if (!empty($find)) {
                     $this->row = get_object_vars($find[0]);
                 }
             }
             if (empty($this->row)) {
                 $this->row = false;
             }
             $current_row_id = $this->row['ID'];
             $get_table_data = true;
         } elseif ('taxonomy' == $this->pod_data['type']) {
             $taxonomy = $this->pod_data['object'];
             if (empty($taxonomy)) {
                 $taxonomy = $this->pod_data['name'];
             }
             if ('id' == $mode) {
                 $this->row = get_term($id, $taxonomy, ARRAY_A);
             } else {
                 $this->row = get_term_by('slug', $id, $taxonomy, ARRAY_A);
             }
             if (empty($this->row)) {
                 $this->row = false;
             }
             $current_row_id = $this->row['term_id'];
             $get_table_data = true;
         } elseif ('user' == $this->pod_data['type']) {
             if ('id' == $mode) {
                 $this->row = get_userdata($id);
             } else {
                 $this->row = get_user_by('slug', $id);
             }
             if (empty($this->row)) {
                 $this->row = false;
             } else {
                 $this->row = get_object_vars($this->row);
             }
             $current_row_id = $this->row['ID'];
             $get_table_data = true;
         } elseif ('comment' == $this->pod_data['type']) {
             $this->row = get_comment($id, ARRAY_A);
             // No slug handling here
             if (empty($this->row)) {
                 $this->row = false;
             }
             $current_row_id = $this->row['comment_ID'];
             $get_table_data = true;
         } elseif ('settings' == $this->pod_data['type']) {
             $this->row = array();
             if (empty($this->fields)) {
                 $this->row = false;
             } else {
                 foreach ($this->fields as $field) {
                     if (!in_array($field['type'], $tableless_field_types)) {
                         $this->row[$field['name']] = get_option($this->pod_data['name'] . '_' . $field['name'], null);
                     }
                 }
                 // Force ID
                 $this->id = $this->pod_data['id'];
                 $this->row['option_id'] = $this->id;
             }
         } else {
             $params = array('table' => $this->table, 'where' => "`t`.`{$this->field_id}` = " . (int) $id, 'orderby' => "`t`.`{$this->field_id}` DESC", 'page' => 1, 'limit' => 1, 'search' => false);
             if ('slug' == $mode && !empty($this->field_slug)) {
                 $id = esc_sql($id);
                 $params['where'] = "`t`.`{$this->field_slug}` = '{$id}'";
             }
             $this->row = pods_data()->select($params);
             if (empty($this->row)) {
                 $this->row = false;
             } else {
                 $current_row = (array) $this->row;
                 $this->row = get_object_vars((object) @current($current_row));
             }
         }
         if ('table' == $this->pod_data['storage'] && false !== $get_table_data && is_numeric($current_row_id)) {
             $params = array('table' => $wpdb->prefix . "pods_", 'where' => "`t`.`id` = {$current_row_id}", 'orderby' => "`t`.`id` DESC", 'page' => 1, 'limit' => 1, 'search' => false, 'strict' => true);
             if (empty($this->pod_data['object'])) {
                 $params['table'] .= $this->pod_data['name'];
             } else {
                 $params['table'] .= $this->pod_data['object'];
             }
             $row = pods_data()->select($params);
             if (!empty($row)) {
                 $current_row = (array) $row;
                 $row = get_object_vars((object) @current($current_row));
                 if (is_array($this->row) && !empty($this->row)) {
                     $this->row = array_merge($row, $this->row);
                 } else {
                     $this->row = $row;
                 }
             }
         }
         if (!empty($this->pod)) {
             pods_cache_set($id, $this->row, 'pods_items_' . $this->pod, 0);
         }
     }
     $this->row = $this->do_hook('fetch', $this->row, $id, $this->row_number);
     return $this->row;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:101,代码来源:PodsData.php


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