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


PHP pods_query函数代码示例

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


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

示例1: pods_image_id_from_field

/**
 * Get the Attachment ID for a specific image field
 *
 * @param array|int|string $image The image field array, ID, or guid
 *
 * @return int Attachment ID
 *
 * @since 2.0.5
 */
function pods_image_id_from_field($image)
{
    $id = 0;
    if (!empty($image)) {
        if (is_array($image)) {
            if (isset($image[0])) {
                $id = pods_image_id_from_field($image[0]);
            } elseif (isset($image['ID'])) {
                $id = $image['ID'];
            } elseif (isset($image['guid'])) {
                $id = pods_image_id_from_field($image['guid']);
            } elseif (isset($image['id'])) {
                $id = $image['id'];
            } else {
                $id = pods_image_id_from_field(current($image));
            }
        } else {
            if (false === strpos($image, '.') && is_numeric($image)) {
                $id = $image;
                $the_post_type = get_post_type($id);
                if (false === $the_post_type) {
                    $id = 0;
                } elseif ('attachment' != $the_post_type) {
                    $id = get_post_thumbnail_id($id);
                }
            } else {
                $guid = pods_query("SELECT `ID` FROM @wp_posts WHERE `post_type` = 'attachment' AND `guid` = %s", array($image));
                if (!empty($guid)) {
                    $id = $guid[0]->ID;
                }
            }
        }
    }
    $id = (int) $id;
    return $id;
}
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:45,代码来源:media.php

示例2: pods_query

<?php

/**
 * @package Pods\Upgrade
 */
// Update to 2.0.3
if (version_compare($pods_version, '2.0.3', '<')) {
    // Rename sister_field_id to sister_id
    pods_query("DELETE FROM `@wp_postmeta` WHERE `meta_key` = 'sister_field_id'", false);
    update_option('pods_framework_version', '2.0.3');
}
// Update to 2.3
if (version_compare($pods_version, '2.3', '<')) {
    // Auto activate Advanced Content Types component
    $oldget = $_GET;
    $_GET['toggle'] = 1;
    PodsInit::$components->toggle('advanced-content-types');
    PodsInit::$components->toggle('table-storage');
    $_GET = $oldget;
    // Set autoload on all necessary options to avoid extra queries
    $autoload_options = array('pods_framework_version' => '', 'pods_framework_version_last' => '', 'pods_framework_db_version' => '', 'pods_framework_upgraded_1_x' => '0', 'pods_version' => '', 'pods_component_settings' => '', 'pods_disable_file_browser' => '0', 'pods_files_require_login' => '1', 'pods_files_require_login_cap' => '', 'pods_disable_file_upload' => '0', 'pods_upload_require_login' => '1', 'pods_upload_require_login_cap' => '');
    foreach ($autoload_options as $option_name => $default) {
        $option_value = get_option($option_name, $default);
        delete_option($option_name);
        add_option($option_name, $option_value, '', 'yes');
    }
    update_option('pods_framework_version', '2.3');
}
// Update to 2.3.4
if (version_compare($pods_version, '2.3.4', '<')) {
    if (function_exists('pods_page_flush_rewrites')) {
开发者ID:centaurustech,项目名称:chipin,代码行数:31,代码来源:update.php

示例3: import

 /**
  * Import data from an array or a CSV file.
  *
  * @param mixed $import_data PHP associative array or CSV input
  * @param bool $numeric_mode Use IDs instead of the name field when matching
  * @param string $format Format of import data, options are php or csv
  *
  * @return array IDs of imported items
  *
  * @since 1.7.1
  * @todo This needs some love and use of table_info etc for relationships
  */
 public function import($import_data, $numeric_mode = false, $format = null)
 {
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     if (null === $format && null !== $this->format) {
         $format = $this->format;
     }
     if ('csv' == $format && !is_array($import_data)) {
         $data = pods_migrate('sv', ',')->parse($import_data);
         $import_data = $data['items'];
     }
     pods_query("SET NAMES utf8");
     pods_query("SET CHARACTER SET utf8");
     // Loop through the array of items
     $ids = array();
     // Test to see if it's an array of arrays
     if (!is_array(@current($import_data))) {
         $import_data = array($import_data);
     }
     $pod = $this->load_pod(array('name' => $this->pod));
     if (false === $pod) {
         return pods_error(__('Pod not found', 'pods'), $this);
     }
     $fields = array_merge($pod['fields'], $pod['object_fields']);
     $simple_tableless_objects = PodsForm::simple_tableless_objects();
     foreach ($import_data as $key => $data_row) {
         $data = array();
         // Loop through each field (use $fields so only valid fields get parsed)
         foreach ($fields as $field_name => $field_data) {
             if (!isset($data_row[$field_name]) && !isset($data_row[$field_data['label']])) {
                 continue;
             }
             $field_id = $field_data['id'];
             $type = $field_data['type'];
             $pick_object = isset($field_data['pick_object']) ? $field_data['pick_object'] : '';
             $pick_val = isset($field_data['pick_val']) ? $field_data['pick_val'] : '';
             if (isset($data_row[$field_name])) {
                 $field_value = $data_row[$field_name];
             } else {
                 $field_value = $data_row[$field_data['label']];
             }
             if (null !== $field_value && false !== $field_value && '' !== $field_value) {
                 if ('pick' == $type || in_array($type, PodsForm::file_field_types())) {
                     $field_values = is_array($field_value) ? $field_value : array($field_value);
                     $pick_values = array();
                     foreach ($field_values as $pick_value) {
                         if (in_array($type, PodsForm::file_field_types()) || 'media' == $pick_object) {
                             $where = "`guid` = '" . pods_sanitize($pick_value) . "'";
                             if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                 $where = "`ID` = " . pods_absint($pick_value);
                             }
                             $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = 'attachment' AND {$where} ORDER BY `ID`", $this);
                             if (!empty($result)) {
                                 $pick_values[] = $result[0]->id;
                             }
                         } elseif ('pick' == $type) {
                             $related_pod = false;
                             if ('pod' == $pick_object) {
                                 $related_pod = $this->load_pod(array('name' => $pick_val, 'table_info' => true), false);
                             }
                             if (empty($related_pod)) {
                                 $related_pod = array('id' => 0, 'type' => $pick_object);
                             }
                             if (in_array('taxonomy', array($pick_object, $related_pod['type']))) {
                                 $where = "`t`.`name` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`tt`.`term_id` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `t`.`term_id` AS `id` FROM `{$wpdb->term_taxonomy}` AS `tt` LEFT JOIN `{$wpdb->terms}` AS `t` ON `t`.`term_id` = `tt`.`term_id` WHERE `taxonomy` = '{$pick_val}' AND {$where} ORDER BY `t`.`term_id`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('post_type', array($pick_object, $related_pod['type'])) || in_array('media', array($pick_object, $related_pod['type']))) {
                                 $where = "`post_title` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = '{$pick_val}' AND {$where} ORDER BY `ID`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('user', array($pick_object, $related_pod['type']))) {
                                 $where = "`user_login` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
//.........这里部分代码省略.........
开发者ID:satokora,项目名称:IT354Project,代码行数:101,代码来源:PodsAPI.php

示例4: get_dropdown_values

 /**
  * Get pod or category drop-down values
  *
  * @param array $params
  *
  * @return array
  */
 public function get_dropdown_values($params)
 {
     pods_deprecated('Pods::get_dropdown_values', '2.0');
     global $wpdb;
     $params = (object) $params;
     $params->orderby = empty($params->orderby) ? '' : ' ORDER BY ' . $params->orderby;
     $params->join = empty($params->join) ? '' : ' LEFT JOIN ' . $params->join;
     $where = false !== $params->exclude ? "WHERE `t`.term_id NOT IN ({$params->exclude})" : '';
     if (!empty($params->pick_filter)) {
         $where .= (empty($where) ? ' WHERE ' : ' AND ') . $params->pick_filter;
     }
     if (!empty($params->where)) {
         $where .= (empty($where) ? ' WHERE ' : ' AND ') . $params->where;
     }
     $sql = "\n            SELECT\n                `t`.`{$params->field_id}` AS `id`,\n                `t`.`{$params->field_name}` AS `name`\n            FROM `{$params->table}` AS `t`\n            {$params->join}\n            {$where}\n            {$params->orderby}\n        ";
     //override with custom dropdown values
     $sql = apply_filters('pods_get_dropdown_values', $sql, $params, $this);
     $val = array();
     $result = pods_query($sql);
     foreach ($result as $row) {
         $row = get_object_vars($row);
         $row['active'] = false;
         if (!empty($params->selected_ids)) {
             $row['active'] = in_array($row['id'], $params->selected_ids);
         }
         $val[] = $row;
     }
     return $val;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:36,代码来源:Pods.php

示例5: cleanup

 /**
  *
  */
 public function cleanup()
 {
     /**
      * @var $wpdb WPDB
      */
     global $wpdb;
     foreach ($this->tables as $table) {
         if (false !== strpos($table, "{$wpdb->prefix}pod_") || "{$wpdb->prefix}pod" == $table) {
             pods_query("DROP TABLE `{$table}`", false);
         }
     }
     delete_option('pods_roles');
     delete_option('pods_version');
     delete_option('pods_framework_upgrade_2_0');
     delete_option('pods_framework_upgrade_2_0_sister_ids');
     delete_option('pods_framework_upgraded_1_x');
     delete_option('pods_disable_file_browser');
     delete_option('pods_files_require_login');
     delete_option('pods_files_require_login_cap');
     delete_option('pods_disable_file_upload');
     delete_option('pods_upload_require_login');
     delete_option('pods_upload_require_login_cap');
     pods_query("DELETE FROM `@wp_postmeta` WHERE `meta_key` LIKE '_pods_1x_%'");
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:27,代码来源:PodsUpgrade_2_0_0.php

示例6: pods_unique_slug

/**
 * Build a unique slug
 *
 * @param string $slug The slug value
 * @param string $column_name The column name
 * @param string|array $pod The Pod name or array of Pod data
 * @param int $pod_id The Pod ID
 * @param int $id The item ID
 * @param object $obj (optional)
 *
 * @return string The unique slug name
 * @since 1.7.2
 */
function pods_unique_slug($slug, $column_name, $pod, $pod_id = 0, $id = 0, $obj = null, $strict = true)
{
    $slug = pods_create_slug($slug, $strict);
    $pod_data = array();
    if (is_array($pod)) {
        $pod_data = $pod;
        $pod_id = pods_v_sanitized('id', $pod_data, 0);
        $pod = pods_v_sanitized('name', $pod_data);
    }
    $pod_id = absint($pod_id);
    $id = absint($id);
    if (empty($pod_data)) {
        $pod_data = pods_api()->load_pod(array('id' => $pod_id, 'name' => $pod), false);
    }
    if (empty($pod_data) || empty($pod_id) || empty($pod)) {
        return $slug;
    }
    if ('table' != $pod_data['storage'] || !in_array($pod_data['type'], array('pod', 'table'))) {
        return $slug;
    }
    $check_sql = "\n        SELECT DISTINCT `t`.`{$column_name}` AS `slug`\n        FROM `@wp_pods_{$pod}` AS `t`\n        WHERE `t`.`{$column_name}` = %s AND `t`.`id` != %d\n        LIMIT 1\n    ";
    $slug_check = pods_query(array($check_sql, $slug, $id), $obj);
    if (!empty($slug_check) || apply_filters('pods_unique_slug_is_bad_flat_slug', false, $slug, $column_name, $pod, $pod_id, $id, $pod_data, $obj)) {
        $suffix = 2;
        do {
            $alt_slug = substr($slug, 0, 200 - (strlen($suffix) + 1)) . "-{$suffix}";
            $slug_check = pods_query(array($check_sql, $alt_slug, $id), $obj);
            $suffix++;
        } while (!empty($slug_check) || apply_filters('pods_unique_slug_is_bad_flat_slug', false, $alt_slug, $column_name, $pod, $pod_id, $id, $pod_data, $obj));
        $slug = $alt_slug;
    }
    $slug = apply_filters('pods_unique_slug', $slug, $id, $column_name, $pod, $pod_id, $obj);
    return $slug;
}
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:47,代码来源:data.php

示例7: select

 /**
  * Select items, eventually building dynamic query
  *
  * @param array $params
  *
  * @return array|bool|mixed
  * @since 2.0
  */
 public function select($params)
 {
     global $wpdb;
     $cache_key = $results = false;
     // Debug purposes
     if (1 == pods_var('pods_debug_params', 'get', 0) && pods_is_admin(array('pods'))) {
         pods_debug($params);
     }
     // Get from cache if enabled
     if (null !== pods_var('expires', $params, null, null, true)) {
         $cache_key = md5(serialize(get_object_vars($params)));
         $results = pods_view_get($cache_key, pods_var('cache_mode', $params, 'cache', null, true), 'pods_data_select');
         if (empty($results)) {
             $results = false;
         }
     }
     if (empty($results)) {
         // Build
         $this->sql = $this->build($params);
         // Debug purposes
         if ((1 == pods_var('pods_debug_sql', 'get', 0) || 1 == pods_var('pods_debug_sql_all', 'get', 0)) && pods_is_admin(array('pods'))) {
             echo '<textarea cols="100" rows="24">' . str_replace(array('@wp_users', '@wp_'), array($wpdb->users, $wpdb->prefix), $this->sql) . '</textarea>';
         }
         if (empty($this->sql)) {
             return array();
         }
         // Get Data
         $results = pods_query($this->sql, $this);
         // Cache if enabled
         if (false !== $cache_key) {
             pods_view_set($cache_key, $results, pods_var('expires', $params, 0, null, true), pods_var('cache_mode', $params, 'cache', null, true), 'pods_data_select');
         }
     }
     $results = $this->do_hook('select', $results);
     $this->data = $results;
     $this->row_number = -1;
     // Fill in empty field data (if none provided)
     if ((!isset($this->fields) || empty($this->fields)) && !empty($this->data)) {
         $this->fields = array();
         $data = (array) @current($this->data);
         foreach ($data as $data_key => $data_value) {
             $this->fields[$data_key] = array('label' => ucwords(str_replace('-', ' ', str_replace('_', ' ', $data_key))));
         }
         $this->fields = PodsForm::fields_setup($this->fields);
     }
     $this->total_found_calculated = false;
     $this->total = count((array) $this->data);
     return $this->data;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:57,代码来源:PodsData.php

示例8: delete_attachment

 /**
  * Delete Attachments from relationships
  *
  * @param int $_ID
  */
 public function delete_attachment($_ID)
 {
     global $wpdb;
     $_ID = (int) $_ID;
     do_action('pods_delete_attachment', $_ID);
     $file_types = "'" . implode("', '", PodsForm::file_field_types()) . "'";
     if (!pods_tableless()) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_podsrel` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                        AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`item_id` = {$_ID}";
         pods_query($sql, false);
     }
     // Post Meta
     if (!empty(PodsMeta::$post_types)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_postmeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
     // User Meta
     if (!empty(PodsMeta::$user)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_usermeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
     // Comment Meta
     if (!empty(PodsMeta::$comment)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_commentmeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:31,代码来源:PodsInit.php

示例9: add_option

    add_option('pods_files_require_login_cap', 'upload_files');
    add_option('pods_disable_file_upload', 0);
    add_option('pods_upload_require_login', 0);
    add_option('pods_upload_require_login_cap', 'upload_files');
    update_option('pods_version', '196');
}
if (version_compare($old_version, '1.9.7', '<')) {
    pods_query("ALTER TABLE `@wp_pod` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
    pods_query("ALTER TABLE `@wp_pod` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod` CHANGE `author_id` `author_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT");
    pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `pod_id` `pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `sister_pod_id` `sister_pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `weight` `weight` INT(10) UNSIGNED NULL DEFAULT '0'");
    update_option('pods_version', '197');
}
if (version_compare($old_version, '1.11', '<')) {
    pods_query("ALTER TABLE `@wp_pod` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
    pods_query("ALTER TABLE `@wp_pod` DROP INDEX `datatype_idx`", false);
    pods_query("ALTER TABLE `@wp_pod` ADD INDEX `datatype_row_idx` (`datatype`, `tbl_row_id`)", false);
    pods_query("ALTER TABLE `@wp_pod_rel` DROP INDEX `field_id_idx`", false);
    pods_query("ALTER TABLE `@wp_pod_rel` ADD INDEX `field_pod_idx` (`field_id`, `pod_id`)", false);
    pods_query("ALTER TABLE `@wp_pod_fields` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
    $result = pods_query("SELECT id, name FROM @wp_pod_types");
    foreach ($result as $row) {
        $pod = pods_sanitize($row->name);
        pods_query("ALTER TABLE `@wp_pod_tbl_{$pod}` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
    }
    update_option('pods_version', '001011000');
}
开发者ID:centaurustech,项目名称:chipin,代码行数:31,代码来源:update-1.x.php

示例10: pods_2_alpha_migrate_templates

function pods_2_alpha_migrate_templates()
{
    $api = pods_api();
    $tpl_rows = pods_query("SELECT * FROM `@wp_pods_objects` WHERE `type` = 'template'", false);
    $tpl_ids = array();
    if (empty($tpl_rows)) {
        return $tpl_ids;
    }
    foreach ($tpl_rows as $row) {
        $opts = json_decode($row->options);
        $tpl_params = array('name' => $row->name, 'code' => $opts->code);
        $tpl_ids[] = $api->save_template($tpl_params);
    }
    return $tpl_ids;
}
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:15,代码来源:update-2.0-beta.php


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