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
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;
 }
 /**
  * @return array
  */
 public function get_row(&$counter = 0, $method = null)
 {
     if (!empty($this->row) && 0 < (int) $this->id && 'table' != $method) {
         return $this->row;
     }
     if (is_object($this->pod) && ('Pods' == get_class($this->pod) || 'Pod' == get_class($this->pod))) {
         $this->row = $this->pod->fetch();
     } else {
         $this->row = false;
         if (!empty($this->data)) {
             if (empty($this->data_keys) || count($this->data) != count($this->data_keys)) {
                 $this->data_keys = array_keys($this->data);
             }
             if (count($this->data) == $this->total && isset($this->data_keys[$counter]) && isset($this->data[$this->data_keys[$counter]])) {
                 $this->row = $this->data[$this->data_keys[$counter]];
                 $counter++;
             }
         }
         if (false === $this->row && 0 < (int) $this->id && !empty($this->sql['table'])) {
             $this->pods_data->select(array('table' => $this->sql['table'], 'where' => '`' . $this->sql['field_id'] . '` = ' . (int) $this->id, 'limit' => 1));
             $this->row = $this->pods_data->fetch();
         }
     }
     return $this->row;
 }
Exemplo n.º 3
0
 /**
  * @param $object_type
  * @param null $_null
  * @param int $object_id
  * @param string $meta_key
  * @param string $meta_value
  * @param bool $delete_all
  *
  * @return null
  */
 public function delete_meta($object_type, $_null = null, $object_id = 0, $meta_key = '', $meta_value = '', $delete_all = false)
 {
     if (pods_tableless()) {
         return $_null;
     }
     $object = $this->get_object($object_type, $object_id);
     if (empty($object_id) || empty($object) || !isset($object['fields'][$meta_key])) {
         return $_null;
     }
     // @todo handle $delete_all (delete the field values from all pod items)
     if (!empty($meta_value) && in_array($object['fields'][$meta_key]['type'], PodsForm::tableless_field_types())) {
         if (!is_object(self::$current_field_pod) || self::$current_field_pod->pod != $object['name']) {
             self::$current_field_pod = pods($object['name'], $object_id);
         } elseif (self::$current_field_pod->id() != $object_id) {
             self::$current_field_pod->fetch($object_id);
         }
         $pod = self::$current_field_pod;
         $pod->remove_from($meta_key, $meta_value);
     } else {
         if (!is_object(self::$current_field_pod) || self::$current_field_pod->pod != $object['name']) {
             self::$current_field_pod = pods($object['name']);
         }
         $pod = self::$current_field_pod;
         $pod->save(array($meta_key => null), null, $object_id);
     }
     return $_null;
 }