Class **Phalcon\\Mvc\\Model\\MetaData** ======================================= *implements* :doc:`Phalcon\\DI\\InjectionAwareInterface ` Because Phalcon\\Mvc\\Model requires meta-data like field names, data types, primary keys, etc. this component collect them and store for further querying by Phalcon\\Mvc\\Model. Phalcon\\Mvc\\Model\\MetaData can also use adapters to store temporarily or permanently the meta-data. A standard Phalcon\\Mvc\\Model\\MetaData can be used to query model attributes: .. code-block:: php getAttributes(new Robots()); print_r($attributes); Constants --------- *integer* **MODELS_ATTRIBUTES** *integer* **MODELS_PRIMARY_KEY** *integer* **MODELS_NON_PRIMARY_KEY** *integer* **MODELS_NOT_NULL** *integer* **MODELS_DATA_TYPES** *integer* **MODELS_DATA_TYPES_NUMERIC** *integer* **MODELS_DATE_AT** *integer* **MODELS_DATE_IN** *integer* **MODELS_IDENTITY_COLUMN** *integer* **MODELS_DATA_TYPES_BIND** *integer* **MODELS_AUTOMATIC_DEFAULT_INSERT** *integer* **MODELS_AUTOMATIC_DEFAULT_UPDATE** *integer* **MODELS_COLUMN_MAP** *integer* **MODELS_REVERSE_COLUMN_MAP** Methods --------- protected **_initialize** () Initialize the metadata for certain table public **setDI** (:doc:`Phalcon\\DiInterface ` $dependencyInjector) Sets the DependencyInjector container public :doc:`Phalcon\\DiInterface ` **getDI** () Returns the DependencyInjector container public **setStrategy** (:doc:`Phalcon\\Mvc\\Model\\MetaData\\Strategy\\Introspection ` $strategy) Set the meta-data extraction strategy public :doc:`Phalcon\\Mvc\\Model\\MetaData\\Strategy\\Introspection ` **getStrategy** () Return the strategy to obtain the meta-data public *array* **readMetaData** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Reads the complete meta-data for certain model .. code-block:: php readMetaData(new Robots()); public **readMetaDataIndex** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *int* $index) Reads meta-data for certain model using a MODEL_* constant .. code-block:: php writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name'))); public **writeMetaDataIndex** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *int* $index, *mixed* $data) Writes meta-data for certain model using a MODEL_* constant .. code-block:: php writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name'))); public *array* **readColumnMap** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Reads the ordered/reversed column map for certain model .. code-block:: php readColumnMap(new Robots())); public **readColumnMapIndex** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *int* $index) Reads column-map information for certain model using a MODEL_* constant .. code-block:: php readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP)); public *array* **getAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns table attributes names (fields) .. code-block:: php getAttributes(new Robots())); public *array* **getPrimaryKeyAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns an array of fields which are part of the primary key .. code-block:: php getPrimaryKeyAttributes(new Robots())); public *array* **getNonPrimaryKeyAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns an arrau of fields which are not part of the primary key .. code-block:: php getNonPrimaryKeyAttributes(new Robots())); public *array* **getNotNullAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns an array of not null attributes .. code-block:: php getNotNullAttributes(new Robots())); public *array* **getDataTypes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns attributes and their data types .. code-block:: php getDataTypes(new Robots())); public *array* **getDataTypesNumeric** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns attributes which types are numerical .. code-block:: php getDataTypesNumeric(new Robots())); public *string* **getIdentityField** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns the name of identity field (if one is present) .. code-block:: php getIdentityField(new Robots())); public *array* **getBindTypes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns attributes and their bind data types .. code-block:: php getBindTypes(new Robots())); public *array* **getAutomaticCreateAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns attributes that must be ignored from the INSERT SQL generation .. code-block:: php getAutomaticCreateAttributes(new Robots())); public *array* **getAutomaticUpdateAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns attributes that must be ignored from the UPDATE SQL generation .. code-block:: php getAutomaticUpdateAttributes(new Robots())); public **setAutomaticCreateAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *array* $attributes) Set the attributes that must be ignored from the INSERT SQL generation .. code-block:: php setAutomaticCreateAttributes(new Robots(), array('created_at' => true)); public **setAutomaticUpdateAttributes** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *array* $attributes) Set the attributes that must be ignored from the UPDATE SQL generation .. code-block:: php setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true)); public *array* **getColumnMap** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns the column map if any .. code-block:: php getColumnMap(new Robots())); public *array* **getReverseColumnMap** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model) Returns the reverse column map if any .. code-block:: php getReverseColumnMap(new Robots())); public *boolean* **hasAttribute** (:doc:`Phalcon\\Mvc\\ModelInterface ` $model, *string* $attribute) Check if a model has certain attribute .. code-block:: php hasAttribute(new Robots(), 'name')); public *boolean* **isEmpty** () Checks if the internal meta-data container is empty .. code-block:: php isEmpty()); public **reset** () Resets internal meta-data in order to regenerate it .. code-block:: php reset();