Re: Architecture patterns in PHP

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

 



Hello,

on 12/30/2008 04:27 PM Nathan Nobbe said the following:
>>>> I was following the blog tutorial on cake and here's what I got from
>>>> hitting the post/index page:
>>>>
>>>> 081230 12:51:55           316 Connect     root@localhost on
>>>>                   316 Init DB     cake
>>>>                   316 Query       SHOW TABLES FROM `cake`
>>>>                   316 Query       DESCRIBE `posts`
>>>>                   316 Query       SELECT `Post`.`id`, `Post`.`title`,
>>>> `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS
>>>> `Post`   WHERE 1 = 1
>>>>                   316 Quit
>>> A good framework will allow you to replace the introspection step with a
>>> static definition of the database table, thus easily bypassing the extra
>>> queries. Although, I can't fathom why they've requested all the tables.
>>>
>>> Cheers,
>>> Rob.
>>> --
>>> http://www.interjinn.com
>>> Application and Templating Framework for PHP
>>>
>> To be fair cake did "cache" the show tables/describe magically for a
>> few seconds if I sat there refreshing the page. :)
>>
>> I always generate my Gateways & VO's from table definitions &
>> hand-code any non-crud statements.  I've never really dealt with this
>> stuff before but it is a little disheartening.  I would rather take
>> the 5 minutes re-generating a few files for an updated table versus
>> infinite amounts of computer power wasted trying to just make it work.
>>
> 
> which bodes really well for something like symphony, but im not sure how
> bulky the orm abstraction layer is.  that could end up ruining it in the
> end..

I think that part of the problem here is that those so called ORM
solutions are in reality ROM because they depart from the relational
data model to the object model. Since they do that dynamically, even
when they cache the results of reverse engineer the object model from
the database table structure, there is always some overhead reading
class structures from cache and rebuilding objects.

This article talks precisely about that problem.

http://www.phpclasses.org/blog/post/82-PHP-ObjectRelational-Mapping-ORM-or-ROM.html

Personally I use a code generation based solution named Metastorage. It
lets me defined my object models statically and then it generates
efficient code for the classes that store and retrieve the application
data objects.

http://www.metastorage.net/

This allows more flexibility and productivity than most ActiveRecord
based  approaches, as it supports complex object models with
relationships, validation rules, etc..

Then Metastorage generates smart code that only does what you need.
There are no fat base classes to extend, nor ORM runtime libraries to
include. The generated code is self-contained, i.e. it does all that is
necessary without runtime libraries to add overhead to the execution of
the applications.

In cases that it is not necessary to use persistent objects (because the
objects are not going to be changed), like for instance listing data or
sending newsletters, Metastorage provides the concept of report classes,
i.e. classes that just retrieve data for read-only purposes. It is much
more efficient than using whole persistent objects because it only
retrieves the object variables that you need into arrays.

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
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