PHPackages                             xwero/idable-queries-relational - 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. xwero/idable-queries-relational

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

xwero/idable-queries-relational
===============================

Idable queries package for relational databases

0.3.1(5mo ago)02mitPHPPHP &gt;=8.4

Since Nov 21Pushed 5mo agoCompare

[ Source](https://github.com/xwero/idable-queries-relational)[ Packagist](https://packagist.org/packages/xwero/idable-queries-relational)[ RSS](/packages/xwero-idable-queries-relational/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Idable queries: relational package
==================================

[](#idable-queries-relational-package)

This package provides the functions to execute SQL queries on relational databases.

Overview
--------

[](#overview)

Idable queries are a set of packages that are at the core a multi-database wrapper. While you can use it as a wrapper with the same functions and types per database, the libraries provide an abstraction for the database names and parameters. At the base of the abstraction is the `Identifier` interface. It is nothing more than a library specific name for enums.

```
enum Users implements Indentifier
{
   case Users; // It is recommended use the enun name for the table/collection/set/... to make the identifier more universal
   case Name;
}

```

A backed enum is recommended to separate database name from the enum name.

A SQL query, `SELECT name FROM users WHERE name = 'me';`, can now be written as `SELECT ~Users:Name FROM ~Users:Users WHERE ~Users:Name = :Users:Name;`. A Redis query like `HMSET users name "Hello" email "World"` can be written as `HMSET ~Users:Users ~Users:Name :Users:Name ~Users:Email :Users:Email`. And so on with other database types.

> **note:** The placeholders are case-insensitive, but for the best compilation path in PHP it is recommended to use capitals.&gt; **note:** The placeholders are case-insensitive, but for the best compilation path in PHP it is recommended to use capitals.

To make it easier to add multiple parameters an `CustomParameterIdentifier` attribute can be added to an `Identifier` instance. This signals to the parameter functions that the parameter value will use a transformer to replace a single placeholder.

```
#[CustomParameterIdentfier('Xwero\IdableQueriesRedis\setParameterTransformer')]
enum Set implements Identfier
{
   case Users;
}

```

Now the Redis query can be written as `HMSET ~Users:Users :Set:Users`. And depending on the values in the `IdableParameterCollection` instance the query will be changed. Each database package will have predefined transformer functions. Creating the `Identifier` instance is up to the implementers.

The libraries will have map functions that transform the result of the query in an array-like structure where the key is an `Identifier` instance. As an example the `SELECT ~Users:Name FROM ~Users:Users WHERE ~Users:Name = :Users:Name;` query result called with the `createMapFromFirstLevelResults` function will have the `$map[Users:Name]` value me. This prevents typos when using the results.

The libraries are build with utility in mind. That is why the main functionality is in the functions, rather than in objects. Use as much or as little as you like.

Functions
---------

[](#functions)

### buildStatement

[](#buildstatement)

Transforms a query into a `Statement`. This will be the start of the chain in most cases.

For the parameters it is possible to use a `IdableParameterCollection` or an array depending on the placeholders in the query.

### executeStatement

[](#executestatement)

Executes and optionally returns data for the prepared `Statement`. An output config can be added to make it consistent. Read more about the output behavior in the [Statement](#statement) section.

### executeTransaction

[](#executetransaction)

Allows to execute multiple `Statement` instances. On `Error` a rollback will be executed.

### getFirstLevelMap

[](#getfirstlevelmap)

This is a convenience function that combines `getRow` and `createMapFromFirstLevelResults`.

### getSecondLevelMapCollection

[](#getsecondlevelmapcollection)

This is a convenience function that combines `getRows` and `createMapFromSecondLevelResults`.

### inArrayParameterTransformer

[](#inarrayparametertransformer)

This function is used as the argument of the `CustomParameterIdentifier` attribute when an `IN` parameter needs to be replaced.

### multiInsertParameterTransformer

[](#multiinsertparametertransformer)

This function is used as the argument of the `CustomParameterIdentifier` attribute when multi insert values need to be replaced.

### PDOfyParameterPlaceholder

[](#pdofyparameterplaceholder)

Makes sure a SQL database is not going to complain about characters it doesn't accept.

Is used by the `buildStatement` function.

Types
-----

[](#types)

### Connection

[](#connection)

Implementation of the `RelationalConnection` interface

The class configures a few things on the `PDO` instance:

- The error mode is set to throw exceptions.
- The default fetch mode is set to associate arrays.
- When the `PDO` methods that return a statement it is the library's `Statement` class and not the default `PDOStatement` class.

This means `$staement = $connection->client->prepare('SELECT * FROM users;')` can be used with the functions that use a `Statement` instance as input.

### QueryReturnConfigRelational

[](#queryreturnconfigrelational)

Manipulate the output of the `executeStatement` function and `Statement->run` method with different booleans.

The `trueOnSuccess` boolean is in this package less useful as the underlying database methods also return a boolean.

### RelationalConnection

[](#relationalconnection)

Interface for the connection class.

### Statement

[](#statement-)

Class to create a consistent language. It exposes the `PDO` instance with the client property and the queryString property exposes the database query.

This class has the methods:

- bindParameter: this method wraps `bindParam` for consistency.
- run: this method executes and gets the data if needed. It is possible to change the data output a `config` argument is added that accepts a `QueryReturnConfigRelational` instance otherwise, it returns the least amount of data.

> **note:** The least amount of data is based on the row amount and the field amount. For example, a single row with a single field return the value of the field instead of an array. If you want a consistent use the config argument.

Tips
----

[](#tips)

- Use the namespaces argument of the functions to prevent unexpected results because of typos or changed namespaces.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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 ~2 days

Total

5

Last Release

162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f41aaa323f8e96ef3b41d829de30e74a0826d54b05ad1ddd355a50b0959740a?d=identicon)[xwero](/maintainers/xwero)

---

Top Contributors

[![xwero](https://avatars.githubusercontent.com/u/496309?v=4)](https://github.com/xwero "xwero (5 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/xwero-idable-queries-relational/health.svg)

```
[![Health](https://phpackages.com/badges/xwero-idable-queries-relational/health.svg)](https://phpackages.com/packages/xwero-idable-queries-relational)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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