tags:

views:

64

answers:

1

hi,

My question may be stupid, but i want to clear my doubt.

I am php, mysql developer.

While coding one of table requires objects from class A for each row.

Say it will create no of objects based on of row.

Is this concept is inconsistent ?

Class A
{

function __construct($userid)
{

}
}

class B
{
function action_add($userid)
{

}
}

Therefore Class A needs to create each object for every row of table.

Class B require one object for a table.

Question 1

Using class A (many objects) is inconsitent ?

Question 2

In two classes which is best.

help me out !

Thanks in advance.

+1  A: 

Sorry, I don't understand the context of the question and not sure what you mean by 'inconsistent'. But, these links might help:

Table Data Gateway architectural pattern http://martinfowler.com/eaaCatalog/tableDataGateway.html "An object that acts as a Gateway (466) to a database table. One instance handles all the rows in the table."

Data Mapper architectural pattern http://martinfowler.com/eaaCatalog/dataMapper.html "A layer of Mappers (473) that moves data between objects and a database while keeping them independent of each other and the mapper itself."

Perhaps you need both? One that has access to the entire table and one that represents a row from the table?

Extra stuff: Class B would suffice. But, if you want an extra level of indirection you might want both, one of which is a Data Mapper and one which is a Table Gateway (and have a 3rd class that represents your domain object e.g. a Person). Of course that might be an overkill, but it separates the domain object from the database details.

helloworlder