コード例 #1
0
ファイル: PodsData.php プロジェクト: Ingenex/redesign
 /**
  * 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;
 }
コード例 #2
0
ファイル: general.php プロジェクト: Ingenex/redesign
/**
 * Get a cached value
 *
 * @see PodsView::get
 *
 * @param string $key Key for the cache
 * @param string $group (optional) Key for the group
 * @param string $callback (optional) Callback function to run to set the value if not cached
 *
 * @return bool|mixed|null|void
 *
 * @since 2.3.10
 */
function pods_option_cache_get($key, $group = '', $callback = null)
{
    return pods_view_get($key, 'option-cache', $group, $callback);
}
コード例 #3
0
ファイル: general.php プロジェクト: centaurustech/chipin
/**
 * Get a cached value
 *
 * @see PodsView::get
 *
 * @param string $key Key for the cache
 *
 * @return bool|mixed|null|void
 *
 * @since 2.0
 */
function pods_transient_get($key)
{
    return pods_view_get($key, 'transient');
}