Model/Database Relationship? |
How can you link up the database relationships,
Such as $post = $post_model->find(123); $comments = $post->comments()->where(['active'=>true]); Something along these lines, changing models together to create relationships, without the need of calling each model separately. Post and Comments in separate tables of course. Ive tried to replicate this by creating a new object within one model to chain another, and failed to get it relating to what im looking for. Any ideas to accomplish this without the need of loading each model by themselves? UPDATE: `find()` method doesn't allow chaining. So what this means is relationships within the database have to be called individually. Which means, I'd have to put the ID into each one separately. The result objects wouldn't be allowed to access relationship content which is a bit of a downfall to the query system. I'd really like to avoid having to use find() a bunch of times just to get the content I'm looking for on 1 item. being able to call it dynamically is a huge benefit. |
Messages In This Thread |
Model/Database Relationship? - by idealcastle - 07-22-2016, 03:06 PM
RE: Model/Database Relationship? - by idealcastle - 07-22-2016, 03:29 PM
RE: Model/Database Relationship? - by JayAdra - 07-22-2016, 06:25 PM
RE: Model/Database Relationship? - by idealcastle - 07-23-2016, 05:56 AM
RE: Model/Database Relationship? - by arma7x - 07-23-2016, 06:28 AM
RE: Model/Database Relationship? - by kilishan - 07-24-2016, 09:52 PM
RE: Model/Database Relationship? - by idealcastle - 08-01-2016, 07:48 AM
RE: Model/Database Relationship? - by kilishan - 08-01-2016, 07:58 AM
|