Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.
This repository was archived by the owner on Jul 20, 2020. It is now read-only.

collections as relationship (linking to multiple tables) #8

@WanWizard

Description

@WanWizard

Requested by @jove4015, see http://codeigniter.com/forums/viewreply/951568/:

One feature I’d love to see is the ability to use multiple columns for a foreign key in a relationship.

The idea would be for example, you have an ID column, and a class name column, and you use both together to make a relationship to multiple different models.

Here’s a use case:

You have a group, and a group has members. You have two columns: member_id, and member_class. The member class could be a User object, or another Group object (so it would read out “user”, or “group”), but you can access all of them through the members method. It’s good if you have multiple classes that have similar properties (perhaps implementing the same interface) and can all belong to the same object of another class, but might have some other divergent attributes or methods as well (therefore creating the need for subclasses and separate tables).

Another example is a folder object, which can contain image objects and document objects and video objects, etc, but from the perspective of the folder, they are all just files, and you want to treat them in a uniform way.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions