/* Use associative array to get fields array
351259
function Fields($colname)
	{
		if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
		if (!$this->bind) {
			$this->bind = array();
			for ($i=0; $i < $this->_numOfFields; $i++) {
				$o = $this->FetchField($i);
				$this->bind[strtoupper($o->name)] = $i;
			}
		}

		 return $this->fields[$this->bind[strtoupper($colname)]];
	}
1295999
protected function getFields($data)
    {
        if (is_array($data)) {
            $fields = $data;
        } else {
            $this->checkData($data);
            $fields = $data->fields();
        }

        return $fields;
    }
1205991
public function getFields($indexed = false)
    {
        $result = array();
        foreach( $this->_fields as $field ) {
            if( (!$indexed) || $field->isIndexed ) {
                $result[ $field->name ] = $field->name;
            }
        }
        return $result;
    }
533407
final public function toArray()
    {
        $this->checkRequiredFields();

        $fields = get_object_vars($this);

        $array = [];
        foreach ($fields as $field => $value) {
            $array[$field] = $this->transformToArray($this->getAttribute($field));
        }

        return $array;
    }
435590
public function getFieldValues(string $field_name)
    {
        try {
            $field = [];
            $result = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
            if (array_key_exists($field_name, $result[0])) {
                foreach ($result as $row) {
                    $field[] = $row[$field_name];
                }
            } else {
                throw new \Exception("Field '$field_name' is not present in the current result set.\n");
            }
            return $field;
        } catch (\PDOException $e) {
            die('Error: ' . $e->getMessage());
        } catch (\Exception $e) {
            die("Error: " . $e->getMessage());
        }
    }
256850
protected function _loadFieldData($fields) {
        if (!is_array($fields)) $fields= array($fields);
        else $fields= array_values($fields);
        $criteria= $this->xpdo->newQuery($this->_class, $this->getPrimaryKey());
        $criteria->select($fields);
        if ($rows= xPDOObject :: _loadRows($this->xpdo, $this->_class, $criteria)) {
            $row= $rows->fetch(\PDO::FETCH_ASSOC);
            $rows->closeCursor();
            $this->fromArray($row, '', false, true);
            $this->_lazy= array_diff($this->_lazy, $fields);
        }
    }
366490
protected function getFieldsAsArrays()
    {
        $fields = [];

        foreach ($this->getFields() as $field) {
            $fields[] = $field->toArray();
        }

        return $fields;
    }
1010944
protected function convertFieldsToArray()
    {
        $fields = $this->fields;

        if ( !$fields ) return;

        $fields = preg_split('/, */', $fields);

        foreach($fields as &$bit)
        {
            $columnInfo = preg_split('/ *: */', $bit);

            $bit = new \StdClass;
            $bit->name = array_shift($columnInfo);
            $bit->type = array_shift($columnInfo);

            // If there is a third key, then
            // the user is setting any number
            // of options
            if ( isset($columnInfo[0]) )
            {
                $bit->options = '';
                foreach($columnInfo as $option)
                {
                    $bit->options .= (str_contains($option, '('))
                        ? "->{$option}"
                        : "->{$option}()";
                }
            }
        }

        return $fields;
    }
805565
public static function getField($arrayList, $fieldName = 'id'): array
    {
        $result = [];

        if (!empty($arrayList) && is_array($arrayList)) {
            foreach ($arrayList as $option) {
                if (is_array($option)) {
                    $result[] = $option[$fieldName];
                } elseif (is_object($option)) {
                    if (isset($option->{$fieldName})) {
                        $result[] = $option->{$fieldName};
                    }
                }
            }
        }

        return $result;
    }
902901
public function getFields()
    {
        $fields = array();
        if (isset($this->definition['index'])) {
            $fields[] = $this->getIndex();
        }
        if (isset($this->definition['fields'])) {
            foreach ($this->definition['fields'] as $key => $value) {
                if (!is_numeric($key)) {
                    $fields[] = $key;
                } else {
                    $fields[] = $value;
                }
            }
        }
        return $fields;
    }
915930
protected function getFieldsValues(): array
    {
        $values = [];
        foreach ($this as $propName => $propValue) {
            if ($this->hasColumn($propName) && ! self::isInPrimaryKey($propName)) {
                $values[$propName] = $propValue;
            }
        }

        return $values;
    }
812167
public function fields( $field = null, $option = null ) {

		$field_data = null;

		if ( empty( $this->fields ) ) {
			// No fields found.
			$field_data = array();
		} elseif ( empty( $field ) ) {
			// Return all fields.
			$field_data = (array) $this->fields;
		} elseif ( ! isset( $this->fields[ $field ] ) && ! isset( $this->pod_data['object_fields'][ $field ] ) ) {
			// Field not found.
			$field_data = array();
		} elseif ( empty( $option ) ) {
			// Return all field data.
			if ( isset( $this->fields[ $field ] ) ) {
				$field_data = $this->fields[ $field ];
			} elseif ( isset( $this->pod_data['object_fields'] ) ) {
				$field_data = $this->pod_data['object_fields'][ $field ];
			}
		} else {
			$options = array();

			// Merge options.
			if ( isset( $this->fields[ $field ] ) ) {
				$options = array_merge( $this->fields[ $field ], $this->fields[ $field ]['options'] );
			} elseif ( isset( $this->pod_data['object_fields'] ) ) {
				$options = array_merge( $this->pod_data['object_fields'][ $field ], $this->pod_data['object_fields'][ $field ]['options'] );
			}

			if ( 'data' === $option && in_array( pods_v( 'type', $options ), PodsForm::tableless_field_types(), true ) ) {
				// Get a list of available items from a relationship field.
				$field_data = PodsForm::field_method( 'pick', 'get_field_data', $options );
			} elseif ( isset( $options[ $option ] ) ) {
				// Return option.
				$field_data = $options[ $option ];
			}
		}//end if

		/**
		 * Modify the field data before returning
		 *
		 * @since unknown
		 *
		 * @param array       $field_data The data for the field.
		 * @param string|null $field      The specific field that data is being return for, if set when method is called or null.
		 * @param string|null $option     Value of option param when method was called. Can be used to get a list of available items from a relationship field.
		 * @param Pods|object $this       The current Pods class instance.
		 */
		return apply_filters( 'pods_pods_fields', $field_data, $field, $option, $this );

	}
13931
private static function getFieldNameArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $names = array();

        foreach ($fields as &$field) {
            $names[] = $field->name;
        }

        return $names;
    }
169451
public function toArray()
    {
        $fieldValues = [];
        foreach ($this->fields as $group) {
            foreach ($group as $name => $field) {
                $fieldValues[$name] = $field->getValue();
            }
        }
        return $fieldValues;
    }
1087341
public function &toArrayOf($fieldName, $keyField = null)
    {
        $arr = [];
        foreach ($this as $object) {
            if ($keyField === null) {
                $arr[] = $object->$fieldName;
            } else {
                $arr[$object->$keyField] = $object->$fieldName;
            }
        }

        return $arr;
    }
1139916
public function getFieldsUsed(): array
    {
        $fields = [];

        /** @var Field $node */
        foreach ($this->getNodesOfType(Field::NODE_TYPE) as $node) {
            $fields[$node->getName()] = true;
        }

        return array_keys($fields);
    }
420231
private function getFieldData($field)
    {
        if (!isset($this->_fieldData[$field])) {
            foreach ($this->fields as $f) {
                if (($f['key'] === $field) || ($f['name'] === $field)) {
                    $this->_fieldData[$field] = $f;
                    break;
                }
            }
        }

        if (isset($this->_fieldData[$field])) {
            return $this->_fieldData[$field];
        } else {
            throw new Exception("Field $field does not exist");
        }
    }