diff --git a/examples/1-basic.php b/examples/1-basic.php index 8bedde4..acb95d5 100644 --- a/examples/1-basic.php +++ b/examples/1-basic.php @@ -1,16 +1,39 @@ build(); + +/** + * Main class of your application. + */ +final class Application +{ + use DbAutoProperties; + + /** + * This field is automatically connected to the database using the specified Settings. + */ + #[OrmMappedArray(KeyType::STRING, ValueType::INT)] + private DbArray $dbProperty; + + public function __construct( + Settings $settings, + string $tablePrefix + ) { + $this->initDbProperties($settings, $tablePrefix); + } + + public function businessLogic(): void + { + $this->dbProperty['someKey'] = 123; + var_dump($this->dbProperty['someKey']); + } + + public function shutdown(): void + { + // Flush all database caches, saving all changes. + $this->saveDbProperties(); + } +} + + +$app = new Application($settings, 'tablePrefix'); +$app->businessLogic(); +$app->shutdown(); \ No newline at end of file diff --git a/src/Annotations/OrmMappedArray.php b/src/Annotations/OrmMappedArray.php index efd5a65..89f24b1 100644 --- a/src/Annotations/OrmMappedArray.php +++ b/src/Annotations/OrmMappedArray.php @@ -20,10 +20,10 @@ use Attribute; use danog\AsyncOrm\KeyType; use danog\AsyncOrm\ValueType; -/** +/** * Attribute use to autoconfigure ORM properties. - * - * @api + * + * @api */ #[Attribute(Attribute::TARGET_PROPERTY)] final class OrmMappedArray