{"id":22688432,"url":"https://github.com/javanile/hamper","last_synced_at":"2025-04-12T21:52:00.413Z","repository":{"id":56996991,"uuid":"261147568","full_name":"javanile/hamper","owner":"javanile","description":"📚 Modern database library for vtiger","archived":false,"fork":false,"pushed_at":"2022-02-22T17:33:04.000Z","size":750,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T16:01:41.866Z","etag":null,"topics":["adodb","code-quality","database-library","database-manipulation","db","developer-friendly","modern-php","php","php8","vtiger","vtiger-crm-exploit","vtigercrm"],"latest_commit_sha":null,"homepage":"https://hamper.javanile.org","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/javanile.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":"2020-05-04T10:49:42.000Z","updated_at":"2024-06-04T10:10:11.000Z","dependencies_parsed_at":"2022-08-21T14:10:26.938Z","dependency_job_id":null,"html_url":"https://github.com/javanile/hamper","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javanile%2Fhamper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javanile%2Fhamper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javanile%2Fhamper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javanile%2Fhamper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javanile","download_url":"https://codeload.github.com/javanile/hamper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637833,"owners_count":21137538,"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":["adodb","code-quality","database-library","database-manipulation","db","developer-friendly","modern-php","php","php8","vtiger","vtiger-crm-exploit","vtigercrm"],"created_at":"2024-12-10T00:14:25.691Z","updated_at":"2025-04-12T21:52:00.390Z","avatar_url":"https://github.com/javanile.png","language":"PHP","funding_links":["https://www.patreon.com/javanile"],"categories":[],"sub_categories":[],"readme":"# Hamper DB\n\nDeveloper friendly database library for vtiger. Hamper improove the code quality and the readbility of your PHP code around database access and manipulation.\n\n## Why I use it?\n\nHere is a list of compelling reasons to use it\n\n- Avoid old-style loop over results. \n- Use by default associative array for fields.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require javanile/hamper\n```\n\n## Usage\n\nYou simply get your `$hdb` object to access on database\n\n```php\nrequire_once 'vendor/autoload.php';\n\nuse Javanile\\Hamper\\Hamper;\n\n$hdb = Hamper::getInstance();\n```\n\n## 📃 Documentation\n\n\u003e 😎 The documentation lists all the functions you can use to make the code simple and easy to read.   \n\nThe access you have on the data inside the database is based on extraction methods that return `array` \nand that you can easily manipulate with `foreach`.\nUse the functions well because they allow you to take a single record or a list of records or all the values of a column.\nBefore starting to use it, read the list of functions carefully, and you will automatically use the best one based on the context.\nFor each function you are also presented, the **\"😿 Legacy\"**, the version of the old style Vtiger code you can replace with Hamper functions, \ncomparing them, and you will realize how Hamper improves your work.\n\n### All Functions\n\n\n\n#### The following methods are used to manipulate records into database\n\n * [Execute query](#-execute-query) - `$hdb-\u003equery(...)`\n * [Get a single record](#-get-a-single-record) - `$hdb-\u003efetch(...)`\n * [Get a list of records](#-get-a-list-of-records) - `$hdb-\u003efetchAll(...)`\n * [Get a value from record](#-get-a-value-from-record) - `$hdb-\u003efetchValue(...)`\n * [Get value by key column](#-get-value-by-key-column) - `$hdb-\u003evalue(...)`\n * [Check if record exists](#-check-if-record-exists) - `$hdb-\u003eexists(...)`\n * [Insert a record](#-insert-a-record) - `$hdb-\u003einsert(...)`\n * [Get last ID](#-get-last-id) - `$hdb-\u003elastInsertId(...)`\n * [Update a single record](#-update-a-single-record) - `$hdb-\u003eupdate(...)`\n * [Delete a single record](#-delete-a-single-record) - `$hdb-\u003edelete(...)`\n\n\n#### The following methods are used to manipulate database tables and fields\n\n * [Create new table](#-create-new-table) - `$hdb-\u003ecreate(...)`\n\n\n\u003chr/\u003e\n\n## `¶` Execute query\n\nExecutes the given parametric query\n\n#### Usage \n\n```\n$hdb-\u003equery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003equery(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Get a single record\n\nFetches the next row from the result set rows by the given parametric query.\n\n#### Usage \n\n```\n$hdb-\u003efetch($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003efetch(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Get a list of records\n\nReturns an array containing all of the result set rows by the given parametric query.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003efetchAll(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Get a value from record\n\nFetches the next row from the result set rows by the given parametric query.\n\n#### Usage \n\n```\n$hdb-\u003efetchValue($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n$crmId = $hdb-\u003efetchValue(\"SELECT crmid FROM vtiger_crmentity WHERE setype=? AND deleted=0\", [$module]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003efetchValue(...)` function\n\n```php\n$adb = \\PearDatabase::getInstance();\n$result = $adb-\u003epquery(\"SELECT tabid FROM vtiger_tab WHERE name=?\", [$setype]);\n$tabId = $adb-\u003equery_result($result, 0, \"tabid\");\n```\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Get value by key column\n\nExecute a query to check if record with specific key and value exists.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003evalue(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Check if record exists\n\nExecute a query to check if record with specific key and value exists.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003eexists(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Insert a record\n\nInserts the given record within the selected table.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003einsert(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Get last ID\n\nReturn last insert ID value for the selected table.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003elastInsertId(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Update a single record\n\nUpdates the given record with the given data.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003eupdate(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Delete a single record\n\nDeletes the given record within the given table.\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n```php\n// Execute simple query\n$hdb-\u003equery(\"SET NAMES utf8\");\n```\n\n```php\n// Execute prepare query\n$hdb-\u003equery(\"UPDATE vtiger_users SET language = ? WHERE user_name = ?\", [\"en_us\", \"admin\"]);\n```\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003edelete(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n## `¶` Create new table\n\n\n\n#### Usage \n\n```\nquery($sql, $params = [], $options = [])\n```\n\n#### Examples\n\nThis method is useful to handle this situations\n\n#### 😿 Legacy\n\nPlease, replace this kind of legacy code with the `$hdb-\u003ecreate(...)` function\n\n[[back to top ☝]](#documentation)\n\n\u003chr/\u003e\n\n\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n```bash\n$ make install\n```\n\n```bash\n$ make tdd take=tests/HamperDatabaseTest.php \n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email bianco@javanile.org instead of using the issue tracker.\n\n## Socialware\n\nWe highly appreciate if you create a social post on Twitter with following button\n\n[![Share on Twitter](https://img.shields.io/badge/-share%20on%20twitter-blue?logo=twitter\u0026style=for-the-badge)](https://twitter.com/intent/tweet?text=Hello%20world)\n\n## Credits\n\nThis project exists thanks to all the people who contribute.\n\n- [Francesco Bianco](https://github.com/francescobianco)\n- [All Contributors](https://github.com/javanile/hamper/graphs/contributors) \n\n## Support us\n\nJavanile is a community project agency based in Sicily, Italy. \nYou'll find an overview of all our projects [on our website](https://www.javanile.org).\n\nDoes your business depend on our contributions? Reach out us on [Patreon](https://www.patreon.com/javanile). \n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/javanile/hamper/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavanile%2Fhamper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavanile%2Fhamper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavanile%2Fhamper/lists"}