'; ?> DomCore Demos, a WebAbility® Network Project
« Back to the index

\core\WABase Object example

database = 'Connector to database 1'; // we keep the config $this->config = $config; } function getConfig() { return $this->config; } } print "We create the base object:
"; $base = new MyBase(array('config' => 'something' )); print "The base object is automatically assigned to the WAObject static global attibute.
"; class myM extends \core\WAObject { function __construct() { parent::__construct(); } function getDatabase() { return $this->base->database; } function getConfig() { return $this->base->getConfig(); } } print "Let's build any object for our application...
"; $M = new myM(); print "OK

"; print "Let's use the database:
"; print $M->getDatabase(); print "

"; print "Let's use the configuration:
"; print_r($M->getConfig()); print "

"; class myM2 extends \core\WAObject { function __construct() { parent::__construct(); } function changeDatabase() { $this->base->database = 'new database 2'; } } print "Let's build another object to commute the database...
"; $M2 = new myM2(); $M2->changeDatabase(); print "OK

"; print "Let's check the database through the first object:
"; print $M->getDatabase(); print "

"; print "The base object is generally used to set and get the whole system configuration, database connectors, user conectivity and security, and very global I/O methods for the whole system.
"; ?>



« Back to the index