🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Abstract class Phalcon\\Mvc\\Model\\MetaData # Abstract class **Phalcon\\Mvc\\Model\\MetaData** *implements*`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: ``` <pre class="calibre14">``` <?php $metaData = new \Phalcon\Mvc\Model\MetaData\Memory(); $attributes = $metaData->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\_DEFAULT\_VALUES** *integer***MODELS\_EMPTY\_STRING\_VALUES** *integer***MODELS\_COLUMN\_MAP** *integer***MODELS\_REVERSE\_COLUMN\_MAP** ### Methods final protected **\_initialize** (*unknown* $model, *unknown* $key, *unknown* $table, *unknown* $schema) Initialize the metadata for certain table public **setDI** (*unknown* $dependencyInjector) Sets the DependencyInjector container public **getDI** () Returns the DependencyInjector container public **setStrategy** (*unknown* $strategy) Set the meta-data extraction strategy public **getStrategy** () Return the strategy to obtain the meta-data final public **readMetaData** (*unknown* $model) Reads the complete meta-data for certain model ``` <pre class="calibre14">``` <?php print_r($metaData->readMetaData(new Robots()); ``` ``` final public **readMetaDataIndex** (*unknown* $model, *unknown* $index) Reads meta-data for certain model ``` <pre class="calibre14">``` <?php print_r($metaData->readMetaDataIndex(new Robots(), 0); ``` ``` final public **writeMetaDataIndex** (*unknown* $model, *unknown* $index, *unknown* $data) Writes meta-data for certain model using a MODEL\_\* constant ``` <pre class="calibre14">``` <?php print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name'))); ``` ``` final public **readColumnMap** (*unknown* $model) Reads the ordered/reversed column map for certain model ``` <pre class="calibre14">``` <?php print_r($metaData->readColumnMap(new Robots())); ``` ``` final public **readColumnMapIndex** (*unknown* $model, *unknown* $index) Reads column-map information for certain model using a MODEL\_\* constant ``` <pre class="calibre14">``` <?php print_r($metaData->readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP)); ``` ``` public **getAttributes** (*unknown* $model) Returns table attributes names (fields) ``` <pre class="calibre14">``` <?php print_r($metaData->getAttributes(new Robots())); ``` ``` public **getPrimaryKeyAttributes** (*unknown* $model) Returns an array of fields which are part of the primary key ``` <pre class="calibre14">``` <?php print_r($metaData->getPrimaryKeyAttributes(new Robots())); ``` ``` public **getNonPrimaryKeyAttributes** (*unknown* $model) Returns an array of fields which are not part of the primary key ``` <pre class="calibre14">``` <?php print_r($metaData->getNonPrimaryKeyAttributes(new Robots())); ``` ``` public **getNotNullAttributes** (*unknown* $model) Returns an array of not null attributes ``` <pre class="calibre14">``` <?php print_r($metaData->getNotNullAttributes(new Robots())); ``` ``` public **getDataTypes** (*unknown* $model) Returns attributes and their data types ``` <pre class="calibre14">``` <?php print_r($metaData->getDataTypes(new Robots())); ``` ``` public **getDataTypesNumeric** (*unknown* $model) Returns attributes which types are numerical ``` <pre class="calibre14">``` <?php print_r($metaData->getDataTypesNumeric(new Robots())); ``` ``` public *string***getIdentityField** ([*Phalcon\\Mvc\\ModelInterface*](#) $model) Returns the name of identity field (if one is present) ``` <pre class="calibre14">``` <?php print_r($metaData->getIdentityField(new Robots())); ``` ``` public **getBindTypes** (*unknown* $model) Returns attributes and their bind data types ``` <pre class="calibre14">``` <?php print_r($metaData->getBindTypes(new Robots())); ``` ``` public **getAutomaticCreateAttributes** (*unknown* $model) Returns attributes that must be ignored from the INSERT SQL generation ``` <pre class="calibre14">``` <?php print_r($metaData->getAutomaticCreateAttributes(new Robots())); ``` ``` public **getAutomaticUpdateAttributes** (*unknown* $model) Returns attributes that must be ignored from the UPDATE SQL generation ``` <pre class="calibre14">``` <?php print_r($metaData->getAutomaticUpdateAttributes(new Robots())); ``` ``` public **setAutomaticCreateAttributes** (*unknown* $model, *unknown* $attributes) Set the attributes that must be ignored from the INSERT SQL generation ``` <pre class="calibre14">``` <?php $metaData->setAutomaticCreateAttributes(new Robots(), array('created_at' => true)); ``` ``` public **setAutomaticUpdateAttributes** (*unknown* $model, *unknown* $attributes) Set the attributes that must be ignored from the UPDATE SQL generation ``` <pre class="calibre14">``` <?php $metaData->setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true)); ``` ``` public **setEmptyStringAttributes** (*unknown* $model, *unknown* $attributes) Set the attributes that allow empty string values ``` <pre class="calibre14">``` <?php $metaData->setEmptyStringAttributes(new Robots(), array('name' => true)); ``` ``` public **getEmptyStringAttributes** (*unknown* $model) Returns attributes allow empty strings ``` <pre class="calibre14">``` <?php print_r($metaData->getEmptyStringAttributes(new Robots())); ``` ``` public **getDefaultValues** (*unknown* $model) Returns attributes (which have default values) and their default values ``` <pre class="calibre14">``` <?php print_r($metaData->getDefaultValues(new Robots())); ``` ``` public **getColumnMap** (*unknown* $model) Returns the column map if any ``` <pre class="calibre14">``` <?php print_r($metaData->getColumnMap(new Robots())); ``` ``` public **getReverseColumnMap** (*unknown* $model) Returns the reverse column map if any ``` <pre class="calibre14">``` <?php print_r($metaData->getReverseColumnMap(new Robots())); ``` ``` public **hasAttribute** (*unknown* $model, *unknown* $attribute) Check if a model has certain attribute ``` <pre class="calibre14">``` <?php var_dump($metaData->hasAttribute(new Robots(), 'name')); ``` ``` public **isEmpty** () Checks if the internal meta-data container is empty ``` <pre class="calibre14">``` <?php var_dump($metaData->isEmpty()); ``` ``` public **reset** () Resets internal meta-data in order to regenerate it ``` <pre class="calibre14">``` <?php $metaData->reset(); ``` ``` | - [索引](# "总目录") - [下一页](# "Class Phalcon\Mvc\Model\MetaData\Apc") | - [上一页](# "Class Phalcon\Mvc\Model\Message") | - [API Indice](#) »