Doctrine - Multiple models referencing same id field in another model Doctrine - Multiple models referencing same id field in another model sql sql

Doctrine - Multiple models referencing same id field in another model


try if you need,
relations:

Files:  type: many  class: File  local: target_id  foreign: idFiles2:  type: many  class: File  local: id  foreign: id


You can try something like:

columns:    id: { type: integer(4), notnull: true, primary: true, autoincrement: true }    target_id:  { type: integer(4), notnull: true }    model:       { type: string, notnull: true }

Files model needs to know the id and the model of linked entry. So, in Files.class.php you can also specify:

public function getArticles() {    if (strcmp($this->getModel(), 'Articles')) {        return Doctrine::getTable('Articles')->findOneById($this->getTargetId());    } else {        return false;    }}

Probably there's a better way, but in this case you have 1 table, you don't need any more relations, but you have to specify getters/setters by yourself. So it depends on your goals whether this will fir or not.