PHPackages                             phphleb/xdorm - 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. phphleb/xdorm

AbandonedArchivedLibrary

phphleb/xdorm
=============

XD ORM for Micro-Framework HLEB

643.2kPHP

Since Dec 22Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

XD::ORM
=======

[](#xdorm)

#### XD ORM for PHP Micro-Framework HLEB

[](#xd-orm-for-php-micro-framework-hleb)

If you need to install the framework, use the link: [github.com/phphleb/hleb](https://github.com/phphleb/hleb)

#### HLEB

[](#hleb)

A distinctive feature of the micro-framework HLEB is the minimalism of the code and the speed of work. The choice of this framework allows you to launch a full-fledged product with minimal time costs and appeals to documentation; it is easy, simple and fast. At the same time, it solves typical tasks, such as routing, shifting actions to controllers, model support, so, the basic MVC implementation. This is the very minimum you need to quickly launch an application.

#### XD ORM

[](#xd-orm)

In fact, XD ORM is a shell over PHP PDO, designed specifically for the framework HLEB. It is simple and corresponds to the general purpose of the micro framework.

The XD ORM is not included in the original configuration of the framework, so it must be copied to the folder with the vendor/phphleb libraries from the [github.com/phphleb/xdorm](https://github.com/phphleb/xdorm) repository or installed using Composer:

```
$ composer require phphleb/xdorm
```

Connection to the project:

```
// File /app/Optional/MainConnect.php
... [
"XdORM\XD" => "vendor/phphleb/xdorm/XD.php"
] ...
```

You can create queries in basic SQL style for the selected DBMS (any, supported by PDO). The main task implemented in this ORM is to turn the query string into a secure query string.

With knowledge of the SQL syntax, you can start writing the Model immediately. This syntax is interpreted as follows for commands:

```
use XdORM\XD;

XD::any(); // 'ANY'
XD::any_words(); // 'ANY_WORDS'
XD::anyWords(); // 'ANY WORDS'
XD::any()->words(); // 'ANY WORDS'
```

For table names, it is enough to pass them in an array:

```
$query = XD::select(['id', 'name', 'email'])->from(['users']);
 // SELECT `id`, `name`, `email` FROM `users`;
```

Values are inserted as is, but all string values, except for SQL statements and special characters, will be checked using the built-in PDO:

```
$query = XD::select('*')->from(['users'])->where(['name'], '!=', "d'Artanyan")->and(['id'], '=', 1)->limit(1);
// SELECT * FROM `users` WHERE `name` != 'd\'Artanyan' AND `id` = 1 LIMIT 1;

$query = XD::select('*')->from(['users'])->where(['id'])->in('(', 15, ',', 43, ',', 60, ',', 71, ')');
// SELECT * FROM `users` WHERE `id` IN ( 15, 43, 60, 71);
```

To pass an array of values, there is a special method setList():

```
$ids = [15, 43, 60, 71];
$query = XD::select('*')->from(['users'])->where(['id'])->in('(', XD::setList($ids), ',', 156, ',', 200, ')');
// SELECT * FROM `users` WHERE `id` IN ( 15, 43, 60, 71, 156, 200);
```

The connection of the parts of the query can be made between the returned objects XD in any order:

```
$select_user_id = XD::select(['id'])->from(['users'])->where(['id'], '=', 15);
$query = XD::select('*')->from(['tasks'])->where(['user_id'], '=', '(', $select_user_id, ')');
```

Or so:

```
$q = XD::select('*')->from(['users']);

$query = $q->limit(100);
// SELECT * FROM `users` LIMIT 100;

// or (but not the "and", as there will be a concatenation with the previous action)

$query = $q->leftJoin(['tasks'])->on(['users.id'], '=', ['tasks.user_id']);
// SELECT * FROM `users` LEFT JOIN `tasks` ON `users`.`id` = `tasks`.`user_id`;
```

Now you need to run this query and get a result if it is implied. For queries with return data, the following methods exist:

```
$result = $query->getSelectOne(); // Getting one row in the named array.
$result = $query->getSelectValue(); // Getting one value.
$result = $query->getSelect(); // Returns an array of rows as named arrays.
$result = $query->getSelectAll(); // Returns an array of objects whose values can be obtained by the fields of the objects.
```

```
$result = XD::selectCount_('(*)')->from(['users'])->getSelectValue();
// SELECT COUNT(*) FROM `users`;
```

For all other queries that do not return a result set, it is enough to add run() to execute the query.

```
XD::update(['users'])->set(['name'], '=', 'admin')->where(['id'], '=', 1)->run();

XD::dropTable(['users'])->run();
```

In exceptional cases, you can use the execute() method for queries, which returns a PDOStatement object, and take further actions with the latter according to the PDO documentation.

#### Using multiple connections

[](#using-multiple-connections)

The required file "dbase.config.php" does not initially exist and must be copied to the "database" directory from the file "database/default.dbase.config.php". If the XD ORM is not connected to the HLEB framework, then the full path to the configuration file may be specified using the constant XDDB\_PATH\_TO\_CONFIG (the file template is located in the “templates” folder).

A configuration file may contain various variants of database connections; by default, the specified connection name is used from the HLEB\_TYPE\_DB constant. To execute a query to another of the databases specified in the configuration file, you must specify its name in the query execution method used. For example: run('postgresql.first'), getSelectOne('postgresql.second') or getSelect('mysql.name'). The query will be executed with the specified settings.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/add493abc37e54c44eabe920dd9facf7aae69955c84bb8245b561f3fc51708da?d=identicon)[phphleb](/maintainers/phphleb)

---

Top Contributors

[![phphleb](https://avatars.githubusercontent.com/u/48386098?v=4)](https://github.com/phphleb "phphleb (28 commits)")

### Embed Badge

![Health badge](/badges/phphleb-xdorm/health.svg)

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

PHPackages © 2026

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