Lazy-initialize the schema for this Model object, if it is not already manually set in the object. You can declare `protected $_schema = array(...)` to define the schema manually.

Parameters

  • mixed $field Optional. You may pass a field name to get schema information for just one field. Otherwise, an array containing all fields is returned. If `false`, the schema is reset to an empty value. If an array, field definitions contained are appended to the schema.

Returns

array

Source

						public static function schema($field = null) {
		$self = static::_object();

		if ($field === false) {
			return $self->_schema = array();
		}
		if (!$self->_schema) {
			$self->_schema = static::connection()->describe($self::meta('source'), $self->_meta);
			$key = (array) self::meta('key');
			if ($self->_schema && array_intersect($key, array_keys($self->_schema)) != $key) {
				throw new ConfigException('Missing key `' . implode(',', $key) . '` from schema.');
			}
		}
		if (is_string($field) && $field) {
			return isset($self->_schema[$field]) ? $self->_schema[$field] : null;
		}
		return $self->_schema;
	}