[PHP] PHP database interface layer
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(); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On 22 July 2010 15:35, Marc Guay marc.g...@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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On Thu, Jul 22, 2010 at 7:35 AM, Marc Guay marc.g...@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
Re: [PHP] PHP database interface layer
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On Jul 22, 2010, at 3:14 PM, Marc Guay wrote: 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 I kind of had the same reaction when I saw it! I started playing around with it and realized that if I ever make any database changes I'm going to have to regenerate everything! Seems a bit cumbersome to me but I'm an good ol' hand coding and a few helper classes programmer myself! I wound up creating a very light-weight yet flexible framework that has served me well over the past few years. I've been thinking about releasing it but it doesn't follow the traditional model of most of the MVC frameworks I've seen. Take care, Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On Thu, Jul 22, 2010 at 1:14 PM, Marc Guay marc.g...@gmail.com wrote: 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 so you spend a little time up front to sav tons of coding time in the future... change your schema; re-generate the base layer.., o yeah, and it preserves custom logic too (upon regeneration), since that resides in sub classes. i used to hand write db wrapper classes but found it tedious and tended to result in a lack of cohesion through the classes themselves, not to mention being error prone. -nathan
Re: [PHP] PHP database interface layer
On 22 July 2010 21:14, Marc Guay marc.g...@gmail.com wrote: 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. Let me repeat myself: did you have a look at 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
Let me repeat myself: did you have a look at Doctrine2? Hi Peter, I didn't mean to ignore your suggestion, I just got extremely overwealmed by the Doctrine website and didn't even have a response. I get the impression that, like Zend and others, learning how to install and use that would take longer than my 'little' website is worth. Maybe someday when I'm working for a more patient employer who's willing to pay me to learn. Insert laughter here. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php