You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a many to many relation from posts to comments. Right now if I executed: <?php $post->comments
I would get an array of all of the comments associated with that post.
But here is what I propose (roughly): <?php namespace \Orm\Model class InTraverse implements \ArrayAccess{ private $_elements = array(); function __get($prop){ $children = array(); foreach ($this->_elements as $id=>$element) $children[$id] = $element->$prop return $children; } }
And so on with methods etc.
This would allow us to:
<?php $post->comments->message
and would return an array with all the messages from each comment (which can easily be imploded, used for Form::select(), etc.)
The text was updated successfully, but these errors were encountered:
Sorry about all the updates, I accidentally submitted it before I could finish writing about the issue. This would still allow for current usage of the one to many (and many to many) functions, yet still adding a new later of flexibility to the ORM.
Alright, I have coded up a potential solution. This basically causes all data returned by the ORM to be passed into a class in the Orm namespace in a model-level defined class called collection.
Let's say I have a many to many relation from posts to comments. Right now if I executed:
<?php $post->comments
I would get an array of all of the comments associated with that post.
But here is what I propose (roughly):
<?php namespace \Orm\Model class InTraverse implements \ArrayAccess{ private $_elements = array(); function __get($prop){ $children = array(); foreach ($this->_elements as $id=>$element) $children[$id] = $element->$prop return $children; } }
And so on with methods etc.
This would allow us to:
<?php $post->comments->message
and would return an array with all the messages from each comment (which can easily be imploded, used for Form::select(), etc.)
The text was updated successfully, but these errors were encountered: