Object

Object –
An introduction to the usage of Objects with MDB_QueryTool

MDB_QueryTool Object Description

It is possible to use objects as result. A comprehensive example may
be seen in the
intro.

But using objects is not a simple alternative to using arrays as result.
It is also possible to register a custom Class to be returned instead of
the default MDB_QueryTool_Result_Row.
The new resulting class has to be child of the
MDB_QueryTool_Result_Row class.

//instanciate an object of the Car class$car = new Car($dsn);$car->useResult('object');$car->setReturnClass('CarEntity');?>

Controlling class variable access

This can now be used to implement getter and setter and thus regulate
the accessability to the values. In order to block the access to the
class variables from outside they have to be declared as protected.
Declaring them as private would result in also blocking the parent class,
which gets the data, of accessing them. Of course when doing so corresponding
methods have to be implemented to access the variables again.

Example 2 - Restricting class variable access

To keep the example short only methods for dealing with model,
hp and clima have been implemented.