Welcome Guest, Not a member yet? Register   Sign In
Poll: Entity models?
You do not have permission to vote in this poll.
yes
43.18%
19 43.18%
no
18.18%
8 18.18%
maybe
38.64%
17 38.64%
Total 44 vote(s) 100%
* You voted for this item. [Show Results]

Entity models?
#11

I vote No. But bow to greater experience in the matter.

I use the models to represent areas of concern, not tables. I tried on one site to have one model per table but it just didn't work for me. Where do you put queries that get from more than one table, or queries that update several tables?

Even the way I do it now sometimes leaves me scratching my head about which model to put the function in. I think the role of models is very dependent on the nature of the site.

One of the things I truly love about CI is that I can work in any way that suits me with it. I would not want to lose that even if it means that I can work NOT following best practice if I choose to. (I admit also to sometimes putting queries in controllers for quick solutions and small sites).

Paul.
Reply
#12

After working on a new project and thinking about this some more, I would have to vote 'Yes'. I so wish I had something like this right now. Smile
Reply
#13

(This post was last modified: 06-12-2015, 07:41 AM by RWCH.)

(04-16-2015, 11:31 PM)jlp Wrote: What I was suggesting has nothing to do with ORM. It is just a way of having the existing model be able to use something other than stdClass. The "entity model" would represent one record in the returned result set, and could be whatever you want it to be. Properties would be injected into such an object the same way they are in a stdClass object in a result set, but we would then have a way to do something entity-specific with such objects.

So if I understand it right, you want the CodeIgniter DB classes be able to return specific objects (which you call "entiry models" here) and not just collections (read "arrays"). I guess that would be okay...

but the returned objects would be different from my domain objects, like the objects rerturned by mysql_fetch_object (standard PHP) are also different from my domain objects. Wouldn't that make your "enity models" DTO's (data transfer objects)?

If that is true, I still have to map them to my domain objects. In that case the value of using these kind of classes seems limited.

Or can I specify that the returned objects must be of the type of my domain object? That would be cool. Is that possible?

Do I understand it right and are my objections valid? Please explain what the benefits of entity models are ... and how they (could) work

Thanks
Reply
#14

(06-12-2015, 07:36 AM)RWCH Wrote:
(04-16-2015, 11:31 PM)jlp Wrote: What I was suggesting has nothing to do with ORM. It is just a way of having the existing model be able to use something other than stdClass. The "entity model" would represent one record in the returned result set, and could be whatever you want it to be. Properties would be injected into such an object the same way they are in a stdClass object in a result set, but we would then have a way to do something entity-specific with such objects.

Or can I specify that the returned objects must be of the type of my domain object? That would be cool. Is that possible?

I believe that would be the point of such a change. The entity model would be your domain object while the existing model acts, more or less, as a mechanism for retrieving domain objects.

This might be similar to using $this->db->custom_result_object($class_name) instead of using $this->db->result() or $this->db->result_array() when returning database results from your model.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB