{"id":16130184,"url":"https://github.com/lambdacasserole/condense","last_synced_at":"2025-04-15T08:16:46.912Z","repository":{"id":57010880,"uuid":"79796785","full_name":"lambdacasserole/condense","owner":"lambdacasserole","description":"Flat-file database in PHP.","archived":false,"fork":false,"pushed_at":"2017-09-09T23:24:28.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T08:16:41.847Z","etag":null,"topics":["composer","database","flat-file","packagist","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdacasserole.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-23T11:04:43.000Z","updated_at":"2023-09-14T16:03:34.000Z","dependencies_parsed_at":"2022-08-21T13:10:12.399Z","dependency_job_id":null,"html_url":"https://github.com/lambdacasserole/condense","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fcondense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fcondense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fcondense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdacasserole%2Fcondense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdacasserole","download_url":"https://codeload.github.com/lambdacasserole/condense/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249031815,"owners_count":21201357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","database","flat-file","packagist","php"],"created_at":"2024-10-09T22:14:56.194Z","updated_at":"2025-04-15T08:16:46.883Z","avatar_url":"https://github.com/lambdacasserole.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Condense\nFlat-file database in PHP.\n\n![Logo](logo.png)\n\nBased on the [Fllat](https://github.com/wylst/fllat) and [Prequel](https://github.com/wylst/prequel) libraries by [Wylst](https://github.com/wylst). Special mention for [Alfred Xing](https://github.com/alfredxing) who seems to be the main contributor behind both. With added support for:\n\n* Encrypted databases using [php-encryption](https://github.com/defuse/php-encryption) by [Taylor Hornby](https://github.com/defuse)\n* Composer via Packagist\n\n## Installation\nInstall Condense via Composer like this:\n\n```bash\ncomposer require lambdacasserole/condense\n```\n\nOr alternatively, if you're using the PHAR (make sure the `php.exe` executable is in your PATH):\n\n```\nphp composer.phar require lambdacasserole/condense\n```\n\n## Usage\nTo initialize a new database or load an existing one, do this.\n\n```php\n$db = new Database('employees');\n```\n\nThis will, by default, create a file `db/employees.dat` or load that file, if it already exists. You can change the path at which the flat file database will be created thusly.\n\n```php\n$db = new Database('employees', '../storage');\n```\n\nThe constructor also accepts a third parameter which allows you to specify a key to use to encrypt the database with.\n\n```php\n$db = new Database('secrets', '../private', 'my-secret-password');\n```\n\nWhen loading the database again, this same password must be used.\n\n### Create\nUse `insert` to add a record (row) to the database.\n\n```php\n$hire = ['first_name' =\u003e 'Ethan', 'last_name' =\u003e 'Benson', 'salary' =\u003e 20000];\n$employees-\u003einsert($hire);\n```\n\n### Retrieve\nCondense provides several methods for data retrieval.\n\n#### One Value\nUse the `get` method. Specify a field name, another field name, and a value. It will return the value of the first field where (in the same row), the value of the second field matches the given value.\n\n```php\n// Returns the salary of the first employee with the first name 'Ethan' (20000).\n$employees-\u003eget('salary', 'first_name', 'Ethan');\n```\n\n#### Field Subset\nUse the `select` method. Returns some (or all) fields in a table, specified by giving an array of desired field names.\n\n```php\n// Returns the whole database.\n$employees-\u003eselect([]);\n\n// Returns the first name of each employee, for example: \n// [['Ethan'],['Thomas'],['James']]\n$employees-\u003eselect(['first_name']);\n```\n\n### Update\nCondense provides a couple of methods for updating existing data in a database.\n\n#### One Field\nUse the `to` method to update one field for any row satisfying a condition.\n\n```php\n// Change every employee with a first name 'Ethan' to have the surname 'Smithers'.\n$employees-\u003eto('last_name', 'Smithers', 'first_name', 'Ethan');\n```\n\n#### One Row\nUse the `update` method to update a row by index.\n\n```php\n// Change the first row in the database completely.\n$employees-\u003eupdate(0, ['first_name' =\u003e 'Alison', 'last_name' =\u003e 'Bradberry']);\n```\n\n### Delete\nUse the `remove` method to delete a row in the database.\n\n```php\n// Remove the first row in the database.\n$employees-\u003eremove(0);\n```\n\n## Caveats\nThis is a flat file database system. It removes the headache of setting up and configuring a database server, but introduces a few of its own:\n\n* I/O will be _much_ slower due to many disk read/write actions\n* Encrypting a database will hugely affect performance\n* Bugs may arise due to concurrency issues\n* Misconfigured web applications using this library may accidentally allow their databases to be downloaded over HTTP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdacasserole%2Fcondense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdacasserole%2Fcondense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdacasserole%2Fcondense/lists"}