Guest User

Untitled

a guest
Jul 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. #This is the name of your model. the actual table name can be given through the tableName: archives
  2. option
  3. #Usually the name of your model is singular, and capitalized
  4.  
  5. #Your Archive seems to lack a primary key. Doctrine will insert an ID: field that is a primary key if it can't find a primary key. It seems archive_id might be your primary key, so you'd have to add that option (primary: true)
  6. Archive:
  7. #tableName: archives <-- Like so.
  8. columns:
  9. archive_id: { type: integer(11), notnull: true, unique: true }
  10. archive_name: { type: text, notnull: true}
  11.  
  12. authors:
  13. columns:
  14. author_id: { type: integer(11), notnull: true, unique: true }
  15. firstname: { type: varchar(30), notnull: false}
  16. lastname: { type: varchar(30), notnull: false}
  17. username: { type: varchar(20), notnull: true}
  18. password: { type: varchar(32), notnull: true}
  19. signature: { type: text, notnull: true}
  20.  
  21. categories:
  22. columns:
  23. category_id: { type: integer(11), notnull: true, unique: true }
  24. category_name: { type: text, notnull: true}
  25.  
  26. comments:
  27. columns:
  28. comment_id: { type: integer(11), notnull: true, unique: true }
  29. entry_id: { type: integer(11), notnull: true, indexed: true }
  30. comment_name: { type: text, notnull: true}
  31. comment_date: { type: datetime, notnull: true}
  32. comment_email: { type: mediumtext, notnull: true}
  33. comment: { type: longtext, notnull: true}
  34.  
  35. #You don't need "indexed: true", because relations are automatically indexed
  36. entries:
  37. columns:
  38. entry_id: { type: integer(11), notnull: true, unique: true }
  39. category_id: { type: integer(11), notnull: true, indexed: true }
  40. archive_id: { type: integer(11), notnull: true, indexed: true }
  41. date: { type: text, notnull: true}
  42. timestamp: { type: timestamp, notnull: true}
  43. entry_title: { type: text, notnull: true}
  44. entry_content: { type: longtext, notnull: true}
  45. user_id: { type: integer(11), notnull: true, indexed: true }
  46. #Here is an example relation
  47. relations:
  48. #This is the "token" of the relation. This is just a way to differentiate this relation from others
  49. #Doctrine will assume that the model for the relation is the same as the token's name
  50. Archive:
  51. #class: Archive <-- not needed, since doctrine can guess this by default. But if you have two relations pointing to the same class, ie archive_id_1, archive_id_2, then you would need different tokens, but the same class
  52. local: archive_id #The local column of the relation
  53. foreign: archive_id #The foreign column of the relation
  54. #In SQL, this would mean "JOIN entries on entries.archive_id = archives.archive_id
  55. type: one #This is "How many Archives can my Entry have
  56. foreignType: many #Many entries can use the same Archive
  57. alias: Archive #This is the alias you will use when you want to use the relation. If you don't give an explicit alias, doctrine will use the token. $entry->getArchive(); or in DQL entry.Archive
  58. foreignAlias: Entries #This is the alias you can use from Archives to get all the entries for a specific archive.
Add Comment
Please, Sign In to add comment