/** * Gets one, multiple, or all values * @example * // Gets all * $rowObject->get(); * // Gets a * $rowObject->get( 'a' ); * // Gets a, b and c * $rowObject->get( array( 'a', 'b', 'c' ) ); * // Gets all from a joined source * $rowObject->get( 'asset', 'rack' ); * // Gets name from a joined source * $rowObject->get( 'asset', 'rack', 'name' ); * // Gets name and model from a joined source * $rowObject->get( 'asset', 'rack', array( 'name', 'model' ) ); * @param field Optional String of name of field to get value for, or an * Associative Array of fields to get values for. Multiple * gets have associative array results. If a field was * requested that does not exist the field's value will * be null - preventing having to check for existence of * each field before getting. If no argument or null is * passed, all fields will be returned as an Associative * Array. */ public function get($category = null, $type = null, $field = null) { if ($category === null && $type === null && $field === null) { $category = $this->category; $type = $this->type; } if ($type === null && $field === null) { $field = $category; $category = $this->category; $type = $this->type; } if ($field === null) { $results = array(); foreach ($this->row as $columnName => $value) { if (!is_int($columnName)) { if (DataCenterDB::isColumnOfType($category, $type, $columnName)) { $fieldName = DataCenterDB::getFieldName($category, $type, $columnName); $results[$fieldName] = $value; } } } return $results; } elseif (is_array($field)) { $results = array(); foreach ($field as $fieldName) { $columnName = DataCenterDB::getColumnName($category, $type, $fieldName); if (isset($this->row[$columnName])) { $results[$fieldName] = $this->row[$columnName]; } else { $results[$fieldName] = null; } } return $results; } else { $columnName = DataCenterDB::getColumnName($category, $type, $field); if (isset($this->row[$columnName])) { return $this->row[$columnName]; } else { return null; } } }