PodsAPI::export PHP Method

export() public method

Export data from a Pod
Since: 1.7.1
public export ( string | object $pod = null, array $params = null ) : array
$pod string | object The pod name or Pods object
$params array An associative array of parameters
return array Data arrays of all exported pod items
    public function export($pod = null, $params = null)
    {
        if (empty($pod)) {
            $pod = $this->pod;
        }
        $find = array('limit' => -1, 'search' => false, 'pagination' => false);
        if (!empty($params) && isset($params['params'])) {
            $find = array_merge($find, (array) $params['params']);
            unset($params['params']);
            $pod = pods($pod, $find);
        } elseif (!is_object($pod)) {
            $pod = pods($pod, $find);
        }
        $data = array();
        while ($pod->fetch()) {
            $data[$pod->id()] = $this->export_pod_item($params, $pod);
        }
        $data = $this->do_hook('export', $data, $pod->pod, $pod);
        return $data;
    }

Usage Example

Example #1
0
 /**
  * Export data from all items
  *
  * @see PodsAPI::export
  *
  * @param array $params An associative array of parameters
  *
  * @return array Data arrays of all exported pod items
  *
  * @since 2.3
  */
 public function export_data($params = null)
 {
     $defaults = array('fields' => null, 'depth' => 2, 'params' => null);
     if (empty($params)) {
         $params = $defaults;
     } else {
         $params = array_merge($defaults, (array) $params);
     }
     return $this->api->export($this, $params);
 }