From: Marc Guay on
Hi everyone,

I've built a fairly large normalized database schema for a project.
This is fun for me as I like thinking about how everything is
interconnected. Foreign keys are all set up, many-to-many tables are
go, etc, and so on. But now it's time to create an interface between
that database and the website using PHP. I've searched the web and
this is obviously a very common problem with many solutions, but I
can't help but feel that all of the logic I've built into the database
is worth nothing once I start coding. I found this
article/presentation that essentially sums up my frustration:
http://mag-sol.com/talks/lpm/2006/orm/. Up until now I've been
working on smaller projects with only a few tables that don't really
relate to each other, and have found this tool
(http://www.ricocheting.com/code/php/mysql-database-class-wrapper)
very handy for the reasons he explains, but I'm looking for something
a little different. I've looked at RedBean and it seems pretty handy,
but it also requires me to redefine all of the foreign keys I've
already defined, which is annoying. Any hope of something like

// Get company where name='Widgets Inc.' or id=1 or....
$company = $db->get_company("name='Widgets Inc.'");

// Get all clients joined to the company
$clients = $company->get_clients();

// Get all projects joined to the client
$projects = $clients->get_projects();

?
From: Peter Lind on
On 22 July 2010 15:35, Marc Guay <marc.guay(a)gmail.com> wrote:
> Hi everyone,
>
> I've built a fairly large normalized database schema for a project.
> This is fun for me as I like thinking about how everything is
> interconnected.  Foreign keys are all set up, many-to-many tables are
> go, etc, and so on.   But now it's time to create an interface between
> that database and the website using PHP.  I've searched the web and
> this is obviously a very common problem with many solutions, but I
> can't help but feel that all of the logic I've built into the database
> is worth nothing once I start coding.  I found this
> article/presentation that essentially sums up my frustration:
> http://mag-sol.com/talks/lpm/2006/orm/.  Up until now I've been
> working on smaller projects with only a few tables that don't really
> relate to each other, and have found this tool
> (http://www.ricocheting.com/code/php/mysql-database-class-wrapper)
> very handy for the reasons he explains, but I'm looking for something
> a little different.  I've looked at RedBean and it seems pretty handy,
> but it also requires me to redefine all of the foreign keys I've
> already defined, which is annoying.  Any hope of something like
>
> // Get company where name='Widgets Inc.' or id=1 or....
> $company = $db->get_company("name='Widgets Inc.'");
>
> // Get all clients joined to the company
> $clients = $company->get_clients();
>
> // Get all projects joined to the client
> $projects = $clients->get_projects();
>
> ?
>

Have you looked at things like Doctrine2?

Regards
Peter

--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
From: Nathan Nobbe on
On Thu, Jul 22, 2010 at 7:35 AM, Marc Guay <marc.guay(a)gmail.com> wrote:

> Hi everyone,
>
> I've built a fairly large normalized database schema for a project.
> This is fun for me as I like thinking about how everything is
> interconnected. Foreign keys are all set up, many-to-many tables are
> go, etc, and so on. But now it's time to create an interface between
> that database and the website using PHP. I've searched the web and
> this is obviously a very common problem with many solutions, but I
> can't help but feel that all of the logic I've built into the database
> is worth nothing once I start coding. I found this
> article/presentation that essentially sums up my frustration:
> http://mag-sol.com/talks/lpm/2006/orm/. Up until now I've been
> working on smaller projects with only a few tables that don't really
> relate to each other, and have found this tool
> (http://www.ricocheting.com/code/php/mysql-database-class-wrapper)
> very handy for the reasons he explains, but I'm looking for something
> a little different. I've looked at RedBean and it seems pretty handy,
> but it also requires me to redefine all of the foreign keys I've
> already defined, which is annoying. Any hope of something like
>
> // Get company where name='Widgets Inc.' or id=1 or....
> $company = $db->get_company("name='Widgets Inc.'");
>
> // Get all clients joined to the company
> $clients = $company->get_clients();
>
> // Get all projects joined to the client
> $projects = $clients->get_projects();
>
> ?


i recommend propel

http://www.propelorm.org/

-nathan
From: Marc Guay on
> i recommend propel
> http://www.propelorm.org/

This looks hopeful. I'd checked it out before but for some reason
lumped it in with all of the other half-baked tools that didn't do
what I wanted, but even that basic example seems to cover most of what
I want.

Thanks for the suggestions.

Marc
From: Marc Guay on
> i recommend propel
> http://www.propelorm.org/

Holy Moses that thing is a monster. It requires installing extra
libraries (Phing) in order to create an XML schema reverse-engineered
from my existing database. The code looks simple enough but that
installation is brutal. Any other suggestions? I'm thinking of
sticking with good ol' hand coding and a few helper classes.

Marc