class Person extends DataObject { protected $db = array( 'Name' => 'Varchar', 'Age' => 'Int', ); public function populateDefaults() { parent::populateDefaults(); $this->Age = 18; } } $person = new Person(); echo $person->Name; // output: "" echo $person->Age; // output: 18
class Product extends DataObject { protected $db = array( 'Name' => 'Varchar', 'Price' => 'Decimal', ); public function populateDefaults() { parent::populateDefaults(); $this->Price = 0; } } $product = new Product(); echo $product->Name; // output: "" echo $product->Price; // output: 0Package Library: The DataObject class and the `populateDefaults()` method are a part of the SilverStripe framework, which is an open-source PHP web development framework.