{"id":18950202,"url":"https://github.com/junker/hsal","last_synced_at":"2026-05-07T00:39:09.695Z","repository":{"id":57003090,"uuid":"50243479","full_name":"Junker/HSAL","owner":"Junker","description":"HandlerSocket Abstraction Layer for PHP","archived":false,"fork":false,"pushed_at":"2021-01-06T05:32:20.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T23:24:25.721Z","etag":null,"topics":["handlersocket","mariadb","mysql","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/Junker.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":"2016-01-23T15:10:00.000Z","updated_at":"2021-07-31T05:56:17.000Z","dependencies_parsed_at":"2022-08-21T14:10:43.043Z","dependency_job_id":null,"html_url":"https://github.com/Junker/HSAL","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Junker/HSAL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2FHSAL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2FHSAL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2FHSAL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2FHSAL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Junker","download_url":"https://codeload.github.com/Junker/HSAL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2FHSAL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268390481,"owners_count":24243055,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["handlersocket","mariadb","mysql","php"],"created_at":"2024-11-08T13:21:39.882Z","updated_at":"2026-05-07T00:39:09.646Z","avatar_url":"https://github.com/Junker.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Junker/HSAL.svg?branch=master)](https://travis-ci.org/Junker/HSAL)\n[![Latest Stable Version](https://poser.pugx.org/junker/hsal/v/stable)](https://packagist.org/packages/junker/hsal)\n[![Total Downloads](https://poser.pugx.org/junker/hsal/downloads)](https://packagist.org/packages/junker/hsal)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Junker/HSAL/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Junker/HSAL/?branch=master)\n[![License](https://poser.pugx.org/junker/hsal/license)](https://packagist.org/packages/junker/hsal)\n\n\n# HSAL - HandlerSocket Abstraction Layer library for PHP\n\n\n## Requirements\nHSAL requires PHP 5.4 or later.\n\none of handlerSocket Libraries: \n* HSPHP (https://github.com/tz-lom/HSPHP)\n* Handlersocketi (https://github.com/kjdev/php-ext-handlersocketi) [Installation instruction](docs/handlersocketi.md) \n\n\n## Installation\nThe best way to install HSAL is to use a [Composer](https://getcomposer.org/download):\n\n    php composer.phar require junker/hsal\n\n\n\n\n## Examples\n\n```php\nuse HSAL\\HSAL;\n\n$hs = new HSAL('localhost', 'database');\n\n//SELECT id,title FROM pages WHERE id=5\n$page = $hs-\u003efetchAssoc('pages', \n\t['id', 'title'], \n\t[HSAL::INDEX_PRIMARY =\u003e 5]\n); \nprint_r($page); // ['id' =\u003e 5, 'title' =\u003e 'page number 5']\n```\n```php\n//SELECT title FROM pages WHERE id=5\n$title = $hs-\u003efetchColumn('pages', 'title', [HSAL::INDEX_PRIMARY =\u003e 5]); \nprint_r($title); // page number 5\n```\n```php\n//SELECT id,page_id,title FROM pages_lang WHERE page_id=5 AND language_id=2\n$page = $hs-\u003efetchArray('pages_lang', \n\t['id', 'page_id', 'title'], \n\t['page_lang' =\u003e [5,2]]\n); \nprint_r($title); // [21, 5, 'numéro de la page 5']\n```\n```php\n//SELECT id,title FROM pages WHERE view_count\u003e10 LIMIT 5\n$pages = $hs-\u003efetchAll('pages', \n\t['id', 'title'], \n\t['view_count' =\u003e 10], \n\tHSAL::OPERATOR_GREATER, \n\t5\n); \nprint_r($pages); \n// [['id' =\u003e 4, 'title' =\u003e 'page number 4'], ['id' =\u003e 5, 'title' =\u003e 'page number 5']] \n```\n```php\n//can make request to another database(i.e. dev_database) without creating new HSAL instance\n//SELECT title FROM dev_database.pages WHERE id=5\n$title = $hs-\u003efetchColumn('dev_database.pages', 'title', [HSAL::INDEX_PRIMARY =\u003e 5]); \n```\n\n```php\nuse HSAL\\HSAL;\n\n$hs = new HSAL('localhost', 'database', ['driver' =\u003e HSAL::DRIVER_HSPHP, 'port_write' =\u003e 5555]);\n\n$hs-\u003einsert('pages', ['id' =\u003e 6, 'title' =\u003e 'New page']);\n\n$result = $hs-\u003edelete('pages', ['id' =\u003e 6]);\nprint_r($result); // 1\n$result = $hs-\u003edelete('pages', ['id' =\u003e 6]);\nprint_r($result); // 0, because record doesn't exists\n\n$hs-\u003eupdate('pages', ['title' =\u003e 'Best page'], [HSAL::INDEX_PRIMARY =\u003e 5]);\n\n$hs-\u003eincrement('pages', 'view_count', [HSAL::INDEX_PRIMARY =\u003e 5]);\n\n```\n\n\n## API\n\n### Methods\n\n**__construct($host, $database, $options)**\n\nname | description | type\n--- | --- | ---\nhost | ip or hostname of HandlerSocket server | string, required\ndatabase | database name | string, required\noptions | array of options | assoc array, optional\nOptions:\n+ driver: default HSAL::DRIVER_AUTO\n+ port_read: read port (int)\n+ port_write: write port (int)\n+ timeout: timeout, works only for Handlersocketi driver (double, default: 5)\n+ rw_timeout: read/write timeout, works only for Handlersocketi driver (double, default: 5)\n\n___\n\n\n**fetchArray($table, $fields, $index_condition, $operator)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nfields | requested fields | array, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\n___\n\n\n**fetchAssoc($table, $fields, $index_condition, $operator)**\n\nname | description | type\n--- | --- | ---\ntable | table name | (string, required)\nfields | requested fields | array, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\n___\n\n**fetchColumn($table, $field, $index_condition, $operator)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nfield | requested field | string, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\n___\n\n**fetchAll($table, $fields, $index_condition, $operator, $limit, $offset)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nfields | requested field | string, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\nlimit | limit rows | int, optional, default: 1000\noffset | offset | int, optional, default: 0\n___\n\n**delete($table, $index_condition, $operator)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\n___\n\n**insert($table, $values)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nvalues | array of fields with values | assoc array, required\n___\n\n**update($table, $values, $index_condition, $operator)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nvalues | associative array of fields with values | assoc array, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\n___\n\n**increment($table, $field, $index_condition, $operator, $increment)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nfield | requested field | string, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\nincrement | increment value | int, optional, default: 1\n___\n\n**decrement($table, $field, $index_condition, $operator, $decrement)**\n\nname | description | type\n--- | --- | ---\ntable | table name | string, required\nfield | requested field | string, required\nindex_condition | query condition | assoc array, required\noperator | operator for query condition | optional, default: HSAL::OPERATOR_EQUAL\ndecrement | decrement value | int, optional, default: 1\n___\n\n```php\n//Operators\nHSAL::OPERATOR_EQUAL = '=';\nHSAL::OPERATOR_LESS = '\u003c';\nHSAL::OPERATOR_LESS_EQUAL = '\u003c=';\nHSAL::OPERATOR_GREATER = '\u003e';\nHSAL::OPERATOR_GREATER_EQUAL = '\u003e=';\n\n//Drivers\nHSAL::DRIVER_AUTO //auto-detect\nHSAL::DRIVER_HSPHP\nHSAL::DRIVER_HANDLERSOCKETI\n```\n\n\n\n\n## Roadmap\n* php-handlersocket Driver (https://code.google.com/p/php-handlersocket/)\n* batch queries \n* Authorization\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunker%2Fhsal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunker%2Fhsal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunker%2Fhsal/lists"}