{"id":16398321,"url":"https://github.com/rrd108/data-mixer","last_synced_at":"2026-05-03T12:32:56.570Z","repository":{"id":62537719,"uuid":"109709549","full_name":"rrd108/data-mixer","owner":"rrd108","description":"A simple tool to create test data from existing database","archived":false,"fork":false,"pushed_at":"2018-06-13T08:51:34.000Z","size":19,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-19T19:43:52.482Z","etag":null,"topics":["database","mysql","php","testing-tools"],"latest_commit_sha":null,"homepage":null,"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/rrd108.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-11-06T14:59:20.000Z","updated_at":"2018-06-13T08:51:35.000Z","dependencies_parsed_at":"2022-11-02T15:16:35.812Z","dependency_job_id":null,"html_url":"https://github.com/rrd108/data-mixer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rrd108/data-mixer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrd108%2Fdata-mixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrd108%2Fdata-mixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrd108%2Fdata-mixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrd108%2Fdata-mixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rrd108","download_url":"https://codeload.github.com/rrd108/data-mixer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrd108%2Fdata-mixer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32569712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["database","mysql","php","testing-tools"],"created_at":"2024-10-11T05:12:23.665Z","updated_at":"2026-05-03T12:32:56.543Z","avatar_url":"https://github.com/rrd108.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# data-mixer\nA simple PHP tool to create test data from existing database by mixing records.\n\nSometimes you want to test your application with the same amount of data what you\nhave in your production enviroment. This script reads your exisiting data and\nmix its content.\n\n# Installation\n`composer --require-dev rrd108/data-mixer`\n\n# Usage\n1. Create a backup of your production data and copy it to your development enviroment. **NEVER** use this tool in production, as you can accidently mix your data. **NO RESTORE, NO UNDO, NO CANCEL** method, what is mixed once, can not be reverted without a backup.\n\n2. Create a new object in your code. DataMixer accepts the same arguments as PDO.\n`$dataMixer = new DataMixer('mysql:dbname=test;host=localhost', 'user', 'superSecret');`\n\n3. Define your selected fields to be mixed in the `$fields` variable.\n\n4. Get your mixed data and modify it if you want.\n`$mixed = $dataMixer-\u003egetMixed($table, $fields);`\n\n5. Update your records in tha database. This will actually update your database, so be careful, **NO RESTORE, NO UNDO, NO CANCEL** method.\n`$dataMixer-\u003eupdateRows($mixed);`\n\n# `$fields` array\nThe fields defined in `$fields` array will be mixed.\n\n## Simple mixing\n```php\n$fields = ['first_name', 'last_name'];\n```\nIn this case in the `$table` database table all records' `first_name` and `last_name` values will be mixed randomly. All other table fields will be unchaned.\n\nLet's say we have the following *starter* table.\n\n| id | first_name | last_name | passport_number | sex |\n|----|------------|-----------|-----------------|-----|\n| 1  | John       | Doe       | 123456789AA     | M   |\n| 2  | Jane       | Gauranga  | 987456789AA     | F   | \n| 3  | Trevor     | Davis     | 985631458ZZ     | M   |\n\nThe simple mixing *may* give us the following result\n\n| id | first_name | last_name | passport_number | sex |\n|----|------------|-----------|-----------------|-----|\n| 1  | Jane       | Davis     | 123456789AA     | M   |\n| 2  | John       | Gauranga  | 987456789AA     | F   |\n| 3  | Trevor     | Doe       | 985631458ZZ     | M   |\n\nYou can see the names are mixed, but all other data (`passport_number` and `sex`) is unchanged.\n\n## Dependent mixing\n```php\n$fields = [\n    ['first_name' =\u003e 'sex'], \n    'last_name'\n];\n```\nIn this case in the `$table` database table all records' `first_name` and `last_name` values will be mixed randomly like in simple mixing, but `first_name` set to be dependent on the value of the `sex` field. It means on mixing the script will only select first names from other records where the value of the `sex` field is the same.\n\nThe dependent mixing *may* give us the following result from the same *starter* table\n\n| id | first_name | last_name | passport_number | sex |\n|----|------------|-----------|-----------------|-----|\n| 1  | Trevor     | Gauranga  | 123456789AA     | M   |\n| 2  | Jane       | Doe       | 987456789AA     | F   |\n| 3  | John       | Davis     | 985631458ZZ     | M   |\n\nAs we had only one female in our table and `first_name` is dependent on `sex`, there was nobody to mix with the first name. That is why Jane kept her first name.\n\n# CLI Usage\nThe package can be used as a shell script.\n`$ vendor/bin/datamixer`\n\nThe script will ask the PDO dsn string, username and password for connecting to the database, than the table name and the `fileds` array.\n\nThe `fileds` array shoud be define like this:\n`first_name =\u003e sex, last_name`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrd108%2Fdata-mixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frrd108%2Fdata-mixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrd108%2Fdata-mixer/lists"}