PHPackages                             junker/hsal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. junker/hsal

ActiveLibrary[Database &amp; ORM](/categories/database)

junker/hsal
===========

HandlerSocket Abstraction layer

0.2.2(5y ago)2841MITPHPPHP &gt;=5.4

Since Jan 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Junker/HSAL)[ Packagist](https://packagist.org/packages/junker/hsal)[ RSS](/packages/junker-hsal/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (1)

[![Build Status](https://camo.githubusercontent.com/d31b960da554cc8c5939e62cbebab35e94e40b0b36c9c67a4569da03af3d62be/68747470733a2f2f7472617669732d63692e6f72672f4a756e6b65722f4853414c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Junker/HSAL)[![Latest Stable Version](https://camo.githubusercontent.com/03929c3f06b90f3f31a579a1d3a035e9a56c517f69173599b0eec5ba21aaac2d/68747470733a2f2f706f7365722e707567782e6f72672f6a756e6b65722f6873616c2f762f737461626c65)](https://packagist.org/packages/junker/hsal)[![Total Downloads](https://camo.githubusercontent.com/b7e43fc9ebf459c3a13c9942536fd0dd7f1aae5565afde504e464868954bc1cd/68747470733a2f2f706f7365722e707567782e6f72672f6a756e6b65722f6873616c2f646f776e6c6f616473)](https://packagist.org/packages/junker/hsal)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f5dcfb504ea3ea28dd394fa79d3ae4c2aabb52138eaaae8d55aeb5d43197c07d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a756e6b65722f4853414c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Junker/HSAL/?branch=master)[![License](https://camo.githubusercontent.com/1dad81dde17c4d5626083ccde5deb738b5d18d8efeed7bca5355801e9a00a9a9/68747470733a2f2f706f7365722e707567782e6f72672f6a756e6b65722f6873616c2f6c6963656e7365)](https://packagist.org/packages/junker/hsal)

HSAL - HandlerSocket Abstraction Layer library for PHP
======================================================

[](#hsal---handlersocket-abstraction-layer-library-for-php)

Requirements
------------

[](#requirements)

HSAL requires PHP 5.4 or later.

one of handlerSocket Libraries:

- HSPHP ()
- Handlersocketi () [Installation instruction](docs/handlersocketi.md)

Installation
------------

[](#installation)

The best way to install HSAL is to use a [Composer](https://getcomposer.org/download):

```
php composer.phar require junker/hsal

```

Examples
--------

[](#examples)

```
use HSAL\HSAL;

$hs = new HSAL('localhost', 'database');

//SELECT id,title FROM pages WHERE id=5
$page = $hs->fetchAssoc('pages',
	['id', 'title'],
	[HSAL::INDEX_PRIMARY => 5]
);
print_r($page); // ['id' => 5, 'title' => 'page number 5']
```

```
//SELECT title FROM pages WHERE id=5
$title = $hs->fetchColumn('pages', 'title', [HSAL::INDEX_PRIMARY => 5]);
print_r($title); // page number 5
```

```
//SELECT id,page_id,title FROM pages_lang WHERE page_id=5 AND language_id=2
$page = $hs->fetchArray('pages_lang',
	['id', 'page_id', 'title'],
	['page_lang' => [5,2]]
);
print_r($title); // [21, 5, 'numéro de la page 5']
```

```
//SELECT id,title FROM pages WHERE view_count>10 LIMIT 5
$pages = $hs->fetchAll('pages',
	['id', 'title'],
	['view_count' => 10],
	HSAL::OPERATOR_GREATER,
	5
);
print_r($pages);
// [['id' => 4, 'title' => 'page number 4'], ['id' => 5, 'title' => 'page number 5']]
```

```
//can make request to another database(i.e. dev_database) without creating new HSAL instance
//SELECT title FROM dev_database.pages WHERE id=5
$title = $hs->fetchColumn('dev_database.pages', 'title', [HSAL::INDEX_PRIMARY => 5]);
```

```
use HSAL\HSAL;

$hs = new HSAL('localhost', 'database', ['driver' => HSAL::DRIVER_HSPHP, 'port_write' => 5555]);

$hs->insert('pages', ['id' => 6, 'title' => 'New page']);

$result = $hs->delete('pages', ['id' => 6]);
print_r($result); // 1
$result = $hs->delete('pages', ['id' => 6]);
print_r($result); // 0, because record doesn't exists

$hs->update('pages', ['title' => 'Best page'], [HSAL::INDEX_PRIMARY => 5]);

$hs->increment('pages', 'view_count', [HSAL::INDEX_PRIMARY => 5]);
```

API
---

[](#api)

### Methods

[](#methods)

**\_\_construct($host, $database, $options)**

namedescriptiontypehostip or hostname of HandlerSocket serverstring, requireddatabasedatabase namestring, requiredoptionsarray of optionsassoc array, optionalOptions:- driver: default HSAL::DRIVER\_AUTO
- port\_read: read port (int)
- port\_write: write port (int)
- timeout: timeout, works only for Handlersocketi driver (double, default: 5)
- rw\_timeout: read/write timeout, works only for Handlersocketi driver (double, default: 5)

---

**fetchArray($table, $fields, $index\_condition, $operator)**

namedescriptiontypetabletable namestring, requiredfieldsrequested fieldsarray, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUAL---

**fetchAssoc($table, $fields, $index\_condition, $operator)**

namedescriptiontypetabletable name(string, required)fieldsrequested fieldsarray, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUAL---

**fetchColumn($table, $field, $index\_condition, $operator)**

namedescriptiontypetabletable namestring, requiredfieldrequested fieldstring, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUAL---

**fetchAll($table, $fields, $index\_condition, $operator, $limit, $offset)**

namedescriptiontypetabletable namestring, requiredfieldsrequested fieldstring, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUALlimitlimit rowsint, optional, default: 1000offsetoffsetint, optional, default: 0---

**delete($table, $index\_condition, $operator)**

namedescriptiontypetabletable namestring, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUAL---

**insert($table, $values)**

namedescriptiontypetabletable namestring, requiredvaluesarray of fields with valuesassoc array, required---

**update($table, $values, $index\_condition, $operator)**

namedescriptiontypetabletable namestring, requiredvaluesassociative array of fields with valuesassoc array, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUAL---

**increment($table, $field, $index\_condition, $operator, $increment)**

namedescriptiontypetabletable namestring, requiredfieldrequested fieldstring, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUALincrementincrement valueint, optional, default: 1---

**decrement($table, $field, $index\_condition, $operator, $decrement)**

namedescriptiontypetabletable namestring, requiredfieldrequested fieldstring, requiredindex\_conditionquery conditionassoc array, requiredoperatoroperator for query conditionoptional, default: HSAL::OPERATOR\_EQUALdecrementdecrement valueint, optional, default: 1---

```
//Operators
HSAL::OPERATOR_EQUAL = '=';
HSAL::OPERATOR_LESS = '';
HSAL::OPERATOR_GREATER_EQUAL = '>=';

//Drivers
HSAL::DRIVER_AUTO //auto-detect
HSAL::DRIVER_HSPHP
HSAL::DRIVER_HANDLERSOCKETI
```

Roadmap
-------

[](#roadmap)

- php-handlersocket Driver ()
- batch queries
- Authorization

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~452 days

Total

5

Last Release

1955d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1144095?v=4)[Dmitry Kosenkov](/maintainers/Junker)[@Junker](https://github.com/Junker)

---

Top Contributors

[![Junker](https://avatars.githubusercontent.com/u/1144095?v=4)](https://github.com/Junker "Junker (1 commits)")

---

Tags

handlersocketmariadbmysqlphpdatabasemysqlmariadbdbalnosqlhandler socketHandlerSocketpercona

### Embed Badge

![Health badge](/badges/junker-hsal/health.svg)

```
[![Health](https://phpackages.com/badges/junker-hsal/health.svg)](https://phpackages.com/packages/junker-hsal)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[longitude-one/doctrine-spatial

Doctrine multi-platform support for spatial types and functions, compliant with Doctrine 2.19, 3.1, and dev ones (3.2 and 4.0).

891.4M1](/packages/longitude-one-doctrine-spatial)[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
