diff --git a/README.md b/README.md index 6ebf130..b3b3986 100755 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ -# csv +# Comma-Separated Values by RFC 4180 +A lightweight database in pure PHP
+It will perfectly replace complex databases in simple projects +## Requirements +- PHP 8.4 + +## Installation +1. `composer require mirzaev/csv` +2. Create a class that inherits `mirzaev/csv/database` and redefine the `database::FILE` constant +3. Enjoy! + +## Example +```php +write($record); +?> +``` + +## Used by +- My site-article about how i was kidnapped by PMC Wagner operatives [mirzaev/repression](https://git.mirzaev.sexy/mirzaev/repression) +- My decentralized P2P blockchain chats project [mirzaev/notchat](https://git.mirzaev.sexy/mirzaev/notchat) diff --git a/mirzaev/csv/system/database.php b/mirzaev/csv/system/database.php index 215ea94..46ef22e 100644 --- a/mirzaev/csv/system/database.php +++ b/mirzaev/csv/system/database.php @@ -69,14 +69,14 @@ class database /** * Constructor * - * @param array|null $columns Columns + * @param string ...$columns Columns * * @return void */ - public function __construct(?array $columns = null) + public function __construct(string ...$columns) { // Initializing columns - if (isset($columns)) $this->columns = $columns; + if (!empty($columns)) $this->columns = $columns; } /** diff --git a/mirzaev/csv/system/record.php b/mirzaev/csv/system/record.php index 9a3ea43..7da1692 100644 --- a/mirzaev/csv/system/record.php +++ b/mirzaev/csv/system/record.php @@ -43,14 +43,14 @@ class record /** * Constructor * - * @param string|null $row Row for converting to record instance parameters + * @param mixed $parameters Parameter of the record * * @return void */ - public function __construct(?string $row = null) + public function __construct(mixed ...$parameters) { // Initializing parameters - if (isset($row)) $this->parameters = static::deserialize($row); + if (!empty($parameters)) $this->parameters = $parameters; } /** @@ -105,7 +105,7 @@ class record * * @return array Deserialized record */ - public function deserialize(string $row): array + public static function deserialize(string $row): array { // Separating row by commas preg_match_all('/(.*)(?>(?