Re: Newbie: Composition by Association - Pagination Class general question.

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

 



Two things strike me as wrong with your thinking:

(1) The idea that you have a separate DAO for each entity instead of a 
single generic DAO which can act for any entity in the system.
(2) The idea that pagination requires its own class, and therefore needs 
this "is-a" and "has-a" nonsense.

As for (1) even in my pre-OO days I was used to using a single generic DAO 
for all database access. The only time that more than one DAO existed was 
for a different DBMS engine. This is why I have one DAO class for MySQL, one 
for PostgreSQL and another for Oracle. If you are incapable of writing a 
single generic DAO then it just shows that you still have a lot to learn. 
For an idea on how this works take a look at 
http://www.tonymarston.net/php-mysql/databaseobjects.html

As for (2) it should be obvious that pagination is not an entity in its own 
right that has its own properties and methods, it is merely a function which 
can be performed on any entity within the system. It should also be obvious 
that the requirements of pagination cannot be satisfied in a single class as 
some of the processing has to be handled in the presentation (UI) layer 
while the remainder is handled in the data access layer. The presentation 
layer needs a means to submit a request for a particular page number as well 
as the page size (rows per page). These two values are sent to the DAO which 
then translates them into values for LIMIT and OFFSET. After the DAO has 
issued the sql SELECT statement it needs to return two values - the current 
page number and the last available page number. The presentation layer then 
needs a mechanism to display these two values. This is explained in 
http://www.tonymarston.net/php-mysql/pagination.html

If you still don't see how this works then you can run my sample application 
at http://www.tonymarston.net/php-mysql/sample-application.html You can even 
download the code so that you can step through it with your debugger.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org


""MEM"" <talofo@xxxxxxxxx> wrote in message 
000701ca0867$992912e0$cb7b38a0$@com">news:000701ca0867$992912e0$cb7b38a0$@com...
Hello,

I have a Animals DAO class that I'd like to apply a pagination class to it.

Between this two classes, there will be a composition relation (more
precisely, an association one). My question is:

Is a Pagination that "has a" Animal. OR Is a Animal that "has a" pagination?
Should we create on Class Pagination a property named $_animal OR, should we
create on class Animal a property named $_pagination?

I'm inclined to accept the second one, since, if I put the property $_animal
on my classe Pagination, I will end up, on the Pagination Class, with so
many properties as pagination objects... :s



Any help please?
Márcio



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