Exemple #1
0
$model = Model_Post::build()->with($dbCon);
var_dump($dbCon->isConnected());
// true
var_dump($model);
$model->id = 42;
var_dump($model->id);
// 42
var_dump((string) $model);
// Model_Post (post) 42
var_dump(isset($model->title));
// false
var_dump($model->title);
// null
var_dump("#### Immutable");
// Once build it can't be changed externally
$modelImmut = Model_Post::buildImmutable()->with($dbCon);
var_dump(isset($modelImmut->id));
// false
try {
    $modelImmut->id = 25;
} catch (Exception $e) {
    var_dump($e->getMessage());
    // Exception thrown
}
var_dump(isset($modelImmut->id));
// false
$modelImmut->setId(22);
var_dump($modelImmut->id);
// 22
var_dump(isset($modelImmut->title));
// false