PHP classes: need help to inherit two classes

I need help developing my PHP classes in which I need to move from multiple classes.

I have a generic Pagination.php class that does all kinds of pagination and sorting. All other classes will use this for pagination.

To make my life easier, I created a class generator that generates a class from a MySQL table. All properties, getters, setters and general methods are created automatically, which really saves time and money.

As an example, the Staff_Base class in Staff_Base.php is automatically created from the t_staff SQL table.

Since the Staff_Base class is automatically created from the SQL table, any "custom" methods / properties are in another class that extends Staff_Base.php. (So ​​whenever a new field is added, I can simply restore the Staff_Base class and overwrite it in Staff_Base.php).

So, I have a class Staff.php that extends Staff_Base.php.

The problem is that Staff.php must also extend another Pagination.php class. (The current workaround is to put the methods in Pagination.php in each class. It is really troublesome when I make changes to the pagination / sorting methods.)

How can I do it? What is the best design for this?

, /. , , Pagination.php.

!

+3
6

Staff_Base.php, Pagination . Staff Staff_Base, Staff_Base Pagination. , , , ( -) .

+1

Staff_Base Pagination? Staff_Base ( )...

Doctrine Propel, , * _Base.

, , , , .

+8

, , , 2 , paginate , .

- . , googled.

+2

, php, Google , ...

0

, . (, Staff) . :

$john = new Staff('John');

? (paginatable?) , , Staff, . , Person, , , .

, , :

  • (Staff_Base )
  • (DAO\Staff , )
  • , , DAO .

, , DAO Staff. Staff_Base ... .

:

 <?php
 $staffDao = new DAO\Staff;
 $staffMembers = $staffDao->getPagedResult($start, $amount);
 ?>

, ,

0

, , PHP . , , , . , ? , , " ".

, ( , , Java) PHP . , , .

Edit: Then __ call () -hack, which can recognize the methods that are actually in your other classes and name them manually.

-one
source

All Articles