jamierumbelow / codeigniter-base-model

⛔️DEPRECATED CodeIgniter base CRUD model to remove repetition and increase productivity
MIT License
1.05k stars 479 forks source link

One to one relationship? #162

Open paulcanning opened 10 years ago

paulcanning commented 10 years ago

The documentation explains how to set up a one-to-many relationship, but who would I do a one to one relationship, when one table is involved in a one-to-many relationship with other tables?

E.g.

Table A --- Table B (one-to-one) Table A -< Table C (one-to-many) (this is set up using $belongs_to="table c" and $has_many="table a")

jamierumbelow commented 10 years ago

When it gets much more complicated than a basic relationship, I'd start writing custom methods and using JOINs. The relationship functionality here is really only for quick rough-and-ready jobs.

On 25 March 2014 16:47, paulcanning notifications@github.com wrote:

The documentation explains how to set up a one-to-many relationship, but who would I do a one to one relationship, when one table is involved in a one-to-many relationship with other tables?

E.g.

Table A --- Table B (one-to-one) Table A -< Table C (one-to-many) (this is set up using $belongs_to="table c" and $has_many="table a")

Reply to this email directly or view it on GitHubhttps://github.com/jamierumbelow/codeigniter-base-model/issues/162 .

Jamie Rumbelow jamie@jamierumbelow.net

paulcanning commented 10 years ago

Hmmm, do you think you would be able to add in some extra relationship stuff for a future release?

jamierumbelow commented 10 years ago

Nope, sorry - like I said, the relationship stuff really isn't optimised or clever at all, and neither should it be! Write the JOINs yourself, or, use an ORM (Laravel's Eloquent is rather nice, and can be used outside of Laravel).

On 26 March 2014 10:44, paulcanning notifications@github.com wrote:

Hmmm, do you think you would be able to add in some extra relationship stuff for a future release?

Reply to this email directly or view it on GitHubhttps://github.com/jamierumbelow/codeigniter-base-model/issues/162#issuecomment-38669555 .

Jamie Rumbelow jamie@jamierumbelow.net