NYCPHP Meetup

NYPHP.org

[nycphp-talk] Database Abstraction / ORM

Justin Demaris justin.demaris at gmail.com
Mon May 7 09:57:35 EDT 2012


One other feature that I would be interested in is friendliness to unit
tests. Is it possible to easily set up faux-objects and pass them around
without having them hit the database? Is it possible to use some of the
more complex fetching and management operations without actually hitting a
real database?

I had a debate on the values of data mapping vs active records a while ago
with a coworker and from my understanding, data mapping isn't so much
"completely different" from the active record approach as it is the next
logical evolutionary step to support the needs of large application
development. A lot of the ideas of data mapping have been filtering their
way back into simpler ORM systems like Yii that still call themselves
"Active Record".

Back to the point, how well does Doctrine 2 play with unit tests?

On Mon, May 7, 2012 at 9:43 AM, guilhermeblanco at gmail.com <
guilhermeblanco at gmail.com> wrote:

> Hi,
>
> I'm one of the Doctrine developers and I can assure you the extra data
> mapper you mentioned is easier than you imagine.
>
> There's a reason for that and that's probably what separates the tools
> for creating simple websites to huge ones. One simple example is how
> you map composite keys, how to deal with inheritance, etc. Trying a
> very quick look to RedBeanPHP I couldn't see any of these support.
>
> Also, people tend to compare Doctrine 1 and Doctrine 2. They can't be
> compared. The first one implemented ActiveRecord while the second is a
> DataMapper. They are fundamentally different and the approaches are
> completely different.
> Lastly, you may miss the old behaviors that Doctrine 1 had, like
> NestedSet, Sluggable, Timestampable, Translatable, etc. You can
> achieve the same by incorporating an extension called Gedmo and
> available at: https://github.com/l3pp4rd/DoctrineExtensions
>
> If you are using Symfony2, the integration is natural and
> configuration is nearly to 0.
>
>
> Thanks,
>
> On Mon, May 7, 2012 at 9:22 AM, Agustin Casiva <casivaagustin at gmail.com>
> wrote:
> > I think that Doctrine is a good alternative, have several features.
> >
> >
> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html
> >
> > Also have a version for Mongo as Backend
> >
> >
> http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
> >
> > Another option is Propel, is more simple and fast but not so powerful
> like
> > doctrine.
> >
> > http://www.propelorm.org/
> >
> > Best Regards
> >
> > On Mon, May 7, 2012 at 9:52 AM, Justin Demaris <justin.demaris at gmail.com
> >
> > wrote:
> >>
> >> Wow, that's pretty cool. My first reaction was pretty strongly against
> >> it... anything that does database voodoo on the fly worries me, but it
> >> allows you freeze the schema or even partially freeze the schema if you
> are
> >> working on adding new features, it has validation hooks, you can build
> in
> >> your own mapper, it has event listeners at key points and it looks like
> it
> >> wouldn't be that hard to adapt it to other data store styles.
> >>
> >> Impressive and thanks!
> >>
> >> ~ Justin
> >>
> >>
> >> On Mon, May 7, 2012 at 8:28 AM, federico ulfo <rainelemental at gmail.com>
> >> wrote:
> >>>
> >>> I suggest to take a look to red bean, is impressive how easy it is and
> >>> right now has one of the most active community!
> >>>
> >>> http://redbeanphp.com
> >>>
> >>>
> >>> Sent from my iPhone
> >>>
> >>> On May 7, 2012, at 8:16 AM, Justin Demaris <justin.demaris at gmail.com>
> >>> wrote:
> >>>
> >>> > Hello PHP Talkers,
> >>> >
> >>> > How do you guys feel about ORM systems and other database abstraction
> >>> > layers? I've been working a lot lately with an older version of
> Kohana
> >>> > (fun!) and doing a lot of performance optimization. A good chunk of
> >>> > improvement has come out of removing reliance on the old Kohana ORM
> and
> >>> > replacing it with simple mysqli calls. Is there any ORM system out
> there
> >>> > that just does it right? Namely, I'd be looking for things like:
> >>> >
> >>> > 1) When I instantiate an object by it's ID multiple times, it doesn't
> >>> > bother to hit up the database after the first time, but just keeps
> giving me
> >>> > copies of the same object
> >>> >
> >>> > 2) Lazy load the object values. There are a number of patterns where
> >>> > I've seen people instantiate a bunch of objects and then only use a
> small
> >>> > subset of them. It would be nice if the object only loaded the data
> when we
> >>> > try to reference one of its non-ID properties.
> >>> >
> >>> > 3) Ability to tweak the back end to work with other database systems
> >>> > (especially Riak, Mongo and Cassandra)
> >>> >
> >>> > I have had really good luck in the past working with Yii and
> >>> > integrating with Redis to use their Active Record structure, but I'm
> not
> >>> > sure of the performance there. Also, I've been hearing a lot about
> Doctrine
> >>> > 2 lately and the necessity of having an extra Data Mapper layer in
> the
> >>> > middle that separates the classes and properties from the fields and
> tables
> >>> > that store the data.
> >>> >
> >>> > Let me know what you guys have experienced, and no pressure since
> this
> >>> > decision is probably going to affect my sleep and happiness for a few
> >>> > years!! ;)
> >>> >
> >>> > ~ Justin DeMaris
> >>> > _______________________________________________
> >>> > New York PHP User Group Community Talk Mailing List
> >>> > http://lists.nyphp.org/mailman/listinfo/talk
> >>> >
> >>> > http://www.nyphp.org/show-participation
> >>> _______________________________________________
> >>> New York PHP User Group Community Talk Mailing List
> >>> http://lists.nyphp.org/mailman/listinfo/talk
> >>>
> >>> http://www.nyphp.org/show-participation
> >>
> >>
> >>
> >> _______________________________________________
> >> New York PHP User Group Community Talk Mailing List
> >> http://lists.nyphp.org/mailman/listinfo/talk
> >>
> >> http://www.nyphp.org/show-participation
> >
> >
> >
> >
> > --
> > Ing. Casiva  Agustin
> >
> > Mail/Msn/GTalk/Jabber: casivaagustin at gmail.com
> > Skype: casivaagustin
> > CEL : 054-03722-15270639
> > Site: http://www.casivaagustin.com.ar
> >
> > _______________________________________________
> > New York PHP User Group Community Talk Mailing List
> > http://lists.nyphp.org/mailman/listinfo/talk
> >
> > http://www.nyphp.org/show-participation
>
>
>
> --
> Guilherme Blanco
> MSN: guilhermeblanco at hotmail.com
> GTalk: guilhermeblanco
> Toronto - ON/Canada
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show-participation
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20120507/a079049c/attachment.html>


More information about the talk mailing list