Fortunes.php 2.1 KB

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