Hello all, I'm sure I'm just missing some logic from the manual, but I can't figure out how to use RB to store existing objects. All examples seem to create objects on the fly.
For example, how would one go about storing and retrieving objects for class A
class B
{
private $b;
public function __construct($b)
{
$this->b=$b;
}
}
class A extends B {
private $a1;
public $a2;
public function __construct()
{
$this->a1=1;
$this->a2=2;
parent::__construct(3);
}
}
I've had a look at the option of using models.
class Model_A extends RedBean_SimpleModel {
private $a1;
public $a2;
public function __construct()
{
$this->a1=1;
$this->a2=2;
parent::__construct(3);
}
}
But properties are not stored in the DB, or retrieved from it, even if they are properties of the model. This happens wether the class members are private or public. There is also the issue that the class can't inherit from the base class B, since PHP doesn't support multiple inheritance
Essentially, I want to build strictly defined classes within PHP, but easily save and restore the objects from the DB.
I'm assuming I'm missing something trivial...