Firstly, it's not a problem to construct classes from a database, i.e. mysql, it's more a question about performance.
If I have a Class A which depends on class B.
class A
{
protected $depend;
public function __construct($id == null)
{
// construct from mysql/postgresql/...
}
}
And in the database has class A (say table "tbl_A") a foreign key to the table of class B (say "tbl_B"). Of course this classes are depending on much more than one table but i will simplify things here...
At the moment i construct class A from it's table:
select * from tbl_A where ID = $id
If they are successful, the statement of class A gives me something like that:
ID | Name | B_ID
1 | "test" | 3
After that i had to construct class B in it's constructor. Is there any possibility to only make one statement with a join in constructor of class A and construct class B from there? I thought this will increase the performance of my application. Badly i don't found any functionality like friend classes (c++, etc) and i want to let my properties of class B stay protected or private.