Pods::fetch PHP Method

fetch() public method

You can rewind the list back to the start by using reset(). Providing an $id will fetch a specific item from a Pod, much like a call to pods(), and can handle either an id or slug.
See also: PodsData::fetch
Since: 2.0
public fetch ( integer $id = null, boolean $explicit_set = true ) : array
$id integer ID or slug of the item to fetch
$explicit_set boolean Whether to set explicitly (use false when in loop)
return array An array of fields from the row
    public function fetch($id = null, $explicit_set = true)
    {
        /**
         * Runs directly before an item is fetched by fetch()
         *
         * @since unknown
         *
         * @param int|string|null $id Item ID being fetched or null.
         * @param object|Pods $this Current Pods object.
         */
        do_action('pods_pods_fetch', $id, $this);
        if (!empty($id)) {
            $this->params = array();
        }
        $this->data->fetch($id, $explicit_set);
        return $this->row;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Get Pod object
  *
  * @since 2.5.6
  *
  * @param $pod_name
  * @param $id
  *
  * @return bool|Pods
  */
 protected static function get_pod($pod_name, $id)
 {
     if (!self::$pod || self::$pod->pod != $pod_name) {
         self::$pod = pods($pod_name, $id, true);
     }
     if (self::$pod && self::$pod->id != $id) {
         self::$pod->fetch($id);
     }
     return self::$pod;
 }
All Usage Examples Of Pods::fetch