/** * 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; }
/** * @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; }