PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/ide/0.8.0/Phalcon/Mvc/Model/MetaData.php

https://github.com/AntonShevchuk/phalcon-devtools
PHP | 351 lines | 44 code | 65 blank | 242 comment | 0 complexity | a23d9dffe8bd49c7540cd7f10c465ae5 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT
  1. <?php
  2. namespace Phalcon\Mvc\Model {
  3. /**
  4. * Phalcon\Mvc\Model\MetaData
  5. *
  6. * <p>Because Phalcon\Mvc\Model requires meta-data like field names, data types, primary keys, etc.
  7. * this component collect them and store for further querying by Phalcon\Model\Base.
  8. * Phalcon\Mvc\Model\MetaData can also use adapters to store temporarily or permanently the meta-data.</p>
  9. *
  10. * <p>A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes:</p>
  11. *
  12. * <code>
  13. * $metaData = new Phalcon\Mvc\Model\MetaData\Memory();
  14. * $attributes = $metaData->getAttributes(new Robots());
  15. * print_r($attributes);
  16. * </code>
  17. *
  18. */
  19. class MetaData {
  20. const MODELS_ATTRIBUTES = 0;
  21. const MODELS_PRIMARY_KEY = 1;
  22. const MODELS_NON_PRIMARY_KEY = 2;
  23. const MODELS_NOT_NULL = 3;
  24. const MODELS_DATA_TYPES = 4;
  25. const MODELS_DATA_TYPES_NUMERIC = 5;
  26. const MODELS_DATE_AT = 6;
  27. const MODELS_DATE_IN = 7;
  28. const MODELS_IDENTITY_COLUMN = 8;
  29. const MODELS_DATA_TYPES_BIND = 9;
  30. const MODELS_AUTOMATIC_DEFAULT_INSERT = 10;
  31. const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11;
  32. const MODELS_COLUMN_MAP = 0;
  33. const MODELS_REVERSE_COLUMN_MAP = 1;
  34. protected $_metaData;
  35. protected $_columnMap;
  36. /**
  37. * Initialize the metadata for certain table
  38. *
  39. * @param \Phalcon\Mvc\ModelInterface $model
  40. * @param string $key
  41. * @param string $table
  42. * @param string $schema
  43. */
  44. protected function _initialize(){ }
  45. /**
  46. * Reads the complete meta-data for certain model
  47. *
  48. *<code>
  49. *print_r($metaData->readMetaData(new Robots());
  50. *</code>
  51. *
  52. * @param \Phalcon\Mvc\ModelInterface $model
  53. * @return array
  54. */
  55. public function readMetaData($model){ }
  56. /**
  57. * Reads meta-data for certain model using a MODEL_* constant
  58. *
  59. *<code>
  60. * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
  61. *</code>
  62. *
  63. * @param \Phalcon\Mvc\ModelInterface $model
  64. * @param int $index
  65. */
  66. public function readMetaDataIndex($model, $index){ }
  67. /**
  68. * Writes meta-data for certain model using a MODEL_* constant
  69. *
  70. *<code>
  71. * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
  72. *</code>
  73. *
  74. * @param \Phalcon\Mvc\ModelInterface $model
  75. * @param int $index
  76. * @param mixed $data
  77. */
  78. public function writeMetaDataIndex($model, $index, $data){ }
  79. /**
  80. * Reads the ordered/reversed column map for certain model
  81. *
  82. *<code>
  83. * print_r($metaData->readColumnMap(new Robots()));
  84. *</code>
  85. *
  86. * @param \Phalcon\Mvc\ModelInterface $model
  87. * @return array
  88. */
  89. public function readColumnMap($model){ }
  90. /**
  91. * Reads column-map information for certain model using a MODEL_* constant
  92. *
  93. *<code>
  94. *print_r($metaData->readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP));
  95. *</code>
  96. *
  97. * @param \Phalcon\Mvc\ModelInterface $model
  98. * @param int $index
  99. */
  100. public function readColumnMapIndex($model, $index){ }
  101. /**
  102. * Returns table attributes names (fields)
  103. *
  104. *<code>
  105. *print_r($metaData->getAttributes(new Robots()));
  106. *</code>
  107. *
  108. * @param \Phalcon\Mvc\ModelInterface $model
  109. * @return array
  110. */
  111. public function getAttributes($model){ }
  112. /**
  113. * Returns an array of fields which are part of the primary key
  114. *
  115. *<code>
  116. *print_r($metaData->getPrimaryKeyAttributes(new Robots()));
  117. *</code>
  118. *
  119. * @param \Phalcon\Mvc\ModelInterface $model
  120. * @return array
  121. */
  122. public function getPrimaryKeyAttributes($model){ }
  123. /**
  124. * Returns an arrau of fields which are not part of the primary key
  125. *
  126. *<code>
  127. *print_r($metaData->getNonPrimaryKeyAttributes(new Robots()));
  128. *</code>
  129. *
  130. * @param \Phalcon\Mvc\ModelInterface $model
  131. * @return array
  132. */
  133. public function getNonPrimaryKeyAttributes($model){ }
  134. /**
  135. * Returns an array of not null attributes
  136. *
  137. *<code>
  138. *print_r($metaData->getNotNullAttributes(new Robots()));
  139. *</code>
  140. *
  141. * @param \Phalcon\Mvc\ModelInterface $model
  142. * @return array
  143. */
  144. public function getNotNullAttributes($model){ }
  145. /**
  146. * Returns attributes and their data types
  147. *
  148. *<code>
  149. *print_r($metaData->getDataTypes(new Robots()));
  150. *</code>
  151. *
  152. * @param \Phalcon\Mvc\ModelInterface $model
  153. * @return array
  154. */
  155. public function getDataTypes($model){ }
  156. /**
  157. * Returns attributes which types are numerical
  158. *
  159. *<code>
  160. *print_r($metaData->getDataTypesNumeric(new Robots()));
  161. *</code>
  162. *
  163. * @param \Phalcon\Mvc\ModelInterface $model
  164. * @return array
  165. */
  166. public function getDataTypesNumeric($model){ }
  167. /**
  168. * Returns the name of identity field (if one is present)
  169. *
  170. *<code>
  171. *print_r($metaData->getIdentityField(new Robots()));
  172. *</code>
  173. *
  174. * @param \Phalcon\Mvc\ModelInterface $model
  175. * @return string
  176. */
  177. public function getIdentityField($model){ }
  178. /**
  179. * Returns attributes and their bind data types
  180. *
  181. *<code>
  182. *print_r($metaData->getBindTypes(new Robots()));
  183. *</code>
  184. *
  185. * @param \Phalcon\Mvc\ModelInterface $model
  186. * @return array
  187. */
  188. public function getBindTypes($model){ }
  189. /**
  190. * Returns attributes that must be ignored from the INSERT SQL generation
  191. *
  192. *<code>
  193. *print_r($metaData->getAutomaticCreateAttributes(new Robots()));
  194. *</code>
  195. *
  196. * @param \Phalcon\Mvc\ModelInterface $model
  197. * @return array
  198. */
  199. public function getAutomaticCreateAttributes($model){ }
  200. /**
  201. * Returns attributes that must be ignored from the UPDATE SQL generation
  202. *
  203. *<code>
  204. *print_r($metaData->getAutomaticUpdateAttributes(new Robots()));
  205. *</code>
  206. *
  207. * @param \Phalcon\Mvc\ModelInterface $model
  208. * @return array
  209. */
  210. public function getAutomaticUpdateAttributes($model){ }
  211. /**
  212. * Set the attributes that must be ignored from the INSERT SQL generation
  213. *
  214. *<code>
  215. *$metaData->setAutomaticCreateAttributes(new Robots(), array('created_at' => true));
  216. *</code>
  217. *
  218. * @param \Phalcon\Mvc\ModelInterface $model
  219. * @param array $attributes
  220. */
  221. public function setAutomaticCreateAttributes($model, $attributes){ }
  222. /**
  223. * Set the attributes that must be ignored from the UPDATE SQL generation
  224. *
  225. *<code>
  226. *$metaData->setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true));
  227. *</code>
  228. *
  229. * @param \Phalcon\Mvc\ModelInterface $model
  230. * @param array $attributes
  231. */
  232. public function setAutomaticUpdateAttributes($model, $attributes){ }
  233. /**
  234. * Returns the column map if any
  235. *
  236. *<code>
  237. * print_r($metaData->getColumnMap(new Robots()));
  238. *</code>
  239. *
  240. * @param \Phalcon\Mvc\ModelInterface $model
  241. * @return array
  242. */
  243. public function getColumnMap($model){ }
  244. /**
  245. * Returns the reverse column map if any
  246. *
  247. *<code>
  248. * print_r($metaData->getReverseColumnMap(new Robots()));
  249. *</code>
  250. *
  251. * @param \Phalcon\Mvc\ModelInterface $model
  252. * @return array
  253. */
  254. public function getReverseColumnMap($model){ }
  255. /**
  256. * Check if a model has certain attribute
  257. *
  258. *<code>
  259. *var_dump($metaData->hasAttribute(new Robots(), 'name'));
  260. *</code>
  261. *
  262. * @param \Phalcon\Mvc\ModelInterface $model
  263. * @param string $attribute
  264. * @return boolean
  265. */
  266. public function hasAttribute($model, $attribute){ }
  267. /**
  268. * Checks if the internal meta-data container is empty
  269. *
  270. *<code>
  271. * var_dump($metaData->isEmpty());
  272. *</code>
  273. *
  274. * @return boolean
  275. */
  276. public function isEmpty(){ }
  277. /**
  278. * Resets internal meta-data in order to regenerate it
  279. *
  280. *<code>
  281. * $metaData->reset();
  282. *</code>
  283. */
  284. public function reset(){ }
  285. }
  286. }