Fortunes.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. use Phalcon\Mvc\Model\MetaData;
  3. use Phalcon\Db\Column;
  4. class Fortunes extends \Phalcon\Mvc\Model
  5. {
  6. public $id;
  7. public $message;
  8. public function initialize()
  9. {
  10. $this->setSource('Fortune');
  11. }
  12. public function metaData()
  13. {
  14. return [
  15. // Every column in the mapped table
  16. MetaData::MODELS_ATTRIBUTES => [
  17. 'id',
  18. 'message'
  19. ],
  20. // Every column part of the primary key
  21. MetaData::MODELS_PRIMARY_KEY => [
  22. 'id',
  23. ],
  24. // Every column that isn't part of the primary key
  25. MetaData::MODELS_NON_PRIMARY_KEY => [
  26. 'message'
  27. ],
  28. // Every column that doesn't allows null values
  29. MetaData::MODELS_NOT_NULL => [
  30. 'id',
  31. 'message'
  32. ],
  33. // Every column and their data types
  34. MetaData::MODELS_DATA_TYPES => [
  35. 'id' => Column::TYPE_INTEGER,
  36. 'message' => Column::TYPE_VARCHAR
  37. ],
  38. // The columns that have numeric data types
  39. MetaData::MODELS_DATA_TYPES_NUMERIC => [
  40. 'id' => true
  41. ],
  42. // The identity column, use boolean false if the model doesn't have
  43. // an identity column
  44. MetaData::MODELS_IDENTITY_COLUMN => 'id',
  45. // How every column must be bound/casted
  46. MetaData::MODELS_DATA_TYPES_BIND => [
  47. 'id' => Column::BIND_PARAM_INT,
  48. 'message' => Column::BIND_PARAM_STR
  49. ],
  50. // Fields that must be ignored from INSERT SQL statements
  51. MetaData::MODELS_AUTOMATIC_DEFAULT_INSERT => [],
  52. // Fields that must be ignored from UPDATE SQL statements
  53. MetaData::MODELS_AUTOMATIC_DEFAULT_UPDATE => [],
  54. // Default values for columns
  55. MetaData::MODELS_DEFAULT_VALUES => [],
  56. // Fields that allow empty strings
  57. MetaData::MODELS_EMPTY_STRING_VALUES => [],
  58. ];
  59. }
  60. }