Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is the name of your model. the actual table name can be given through the tableName: archives
- option
- #Usually the name of your model is singular, and capitalized
- #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)
- Archive:
- #tableName: archives <-- Like so.
- columns:
- archive_id: { type: integer(11), notnull: true, unique: true }
- archive_name: { type: text, notnull: true}
- authors:
- columns:
- author_id: { type: integer(11), notnull: true, unique: true }
- firstname: { type: varchar(30), notnull: false}
- lastname: { type: varchar(30), notnull: false}
- username: { type: varchar(20), notnull: true}
- password: { type: varchar(32), notnull: true}
- signature: { type: text, notnull: true}
- categories:
- columns:
- category_id: { type: integer(11), notnull: true, unique: true }
- category_name: { type: text, notnull: true}
- comments:
- columns:
- comment_id: { type: integer(11), notnull: true, unique: true }
- entry_id: { type: integer(11), notnull: true, indexed: true }
- comment_name: { type: text, notnull: true}
- comment_date: { type: datetime, notnull: true}
- comment_email: { type: mediumtext, notnull: true}
- comment: { type: longtext, notnull: true}
- #You don't need "indexed: true", because relations are automatically indexed
- entries:
- columns:
- entry_id: { type: integer(11), notnull: true, unique: true }
- category_id: { type: integer(11), notnull: true, indexed: true }
- archive_id: { type: integer(11), notnull: true, indexed: true }
- date: { type: text, notnull: true}
- timestamp: { type: timestamp, notnull: true}
- entry_title: { type: text, notnull: true}
- entry_content: { type: longtext, notnull: true}
- user_id: { type: integer(11), notnull: true, indexed: true }
- #Here is an example relation
- relations:
- #This is the "token" of the relation. This is just a way to differentiate this relation from others
- #Doctrine will assume that the model for the relation is the same as the token's name
- Archive:
- #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
- local: archive_id #The local column of the relation
- foreign: archive_id #The foreign column of the relation
- #In SQL, this would mean "JOIN entries on entries.archive_id = archives.archive_id
- type: one #This is "How many Archives can my Entry have
- foreignType: many #Many entries can use the same Archive
- 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
- 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