PodsUI::get_row PHP Method

get_row() public method

public get_row ( &$counter, $method = null ) : array
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;
    }

Usage Example

 /**
  * Handle View action
  *
  * @param PodsUI $obj
  * @param string $id
  */
 public static function admin_page_view_job($obj, $id)
 {
     $item = $obj->get_row();
     $item = array_map('maybe_unserialize', $item);
     include_once 'ui/view-job.php';
 }