Re: PHP database interface layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/22/2010 08:35 AM, Marc Guay 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();
> 
> ?

You may not want a full fledged framework, but I would recommend
CakePHP.  Now they have naming conventions for tables/columns, that if
you follow, makes it sooo easy, but if you already have your schema
built it can use that just as easily.

Just run the cake script, enter db details, it will enumerate tables and
columns and ask which are related by which keys and even let you enter
validation rules etc.  It then builds a skeleton app with all the models
for your schema and will even generate test.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux