PHPackages                             drupalheadless/database - 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. drupalheadless/database

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

drupalheadless/database
=======================

A Drupal 7 ORM as headless version

223PHP

Since Dec 18Pushed 9y ago1 watchersCompare

[ Source](https://github.com/juanparati/DrupalHeadless)[ Packagist](https://packagist.org/packages/drupalheadless/database)[ RSS](/packages/drupalheadless-database/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

DrupalHeadless
==============

[](#drupalheadless)

Description
-----------

[](#description)

The DrupalHeadless project provides the following components as a compatible PSR-4 package:

- The original Drupal 7 Database Abstraction Layer
- A replacement for the Entity Field Query

This package was created in order to provide an elegant and suitable way of interact with Drupal 7 databases without the requeriment of install a full Drupal 7 stack. DrupalHeadless can used as with standalone scripts or can be deployed via composer in different solutions like for example Drupal 8.

How to use the database abstraction layer?
------------------------------------------

[](#how-to-use-the-database-abstraction-layer)

If you are familiar with Drupal 7 Database API, then it is going to be easy for you to use the DrupalHeadless database abstraction layer because it is based in the original abstraction layer.

### Database connection and query

[](#database-connection-and-query)

```
 use \DrupalHeadless\Database\Database;

 // Set connection info
 Database::addConnectionInfo('default', 'default', [
     'driver'    => 'mysql',
     'database'  => 'drupal',
     'username'  => 'root',
     'password'  => 'root',
     'host'      => '127.0.0.1',
     'prefix'    => 'drupal_'
 ]);

 $query = Database::getConnection('default', 'default');

 $st = $query->select('node', 'n');

 $result = $st->fields('n')
     ->range(0, 10)
     ->execute()
     ->fetchAll();

```

As an alternative it is also possible to use the statement helper:

```
 use \DrupalHeadless\Database\Database;
 use \DrupalHeadless\Database\DatabaseHelper as DH;

 // Set connection info
 Database::addConnectionInfo('default', 'default', [
     'driver'    => 'mysql',
     'database'  => 'drupal',
     'username'  => 'root',
     'password'  => 'root',
     'host'      => '127.0.0.1',
     'prefix'    => 'drupal_'
 ]);

 $result = DH::select('node', 'n')
     ->fields('n')
     ->range(0, 10)
     ->execute()
     ->fetchAllAssoc('nid');

```

How to use the Entity Field Query?
----------------------------------

[](#how-to-use-the-entity-field-query)

### Select (and retrieve all the fields)

[](#select-and-retrieve-all-the-fields)

```
    use \DrupalHeadless\Database\Database;
    use \DrupalHeadless\Entity\EntityController as EC;
    use \DrupalHeadless\Entity\Model;

    // Set connection info
    Database::addConnectionInfo('default', 'default', [
        'driver'    => 'mysql',
        'database'  => 'drupal',
        'username'  => 'root',
        'password'  => 'root',
        'host'      => '127.0.0.1',
        'prefix'    => 'drupal_'
    ]);

    $connection = Database::getConnection('default', 'default');

    // Search the first 5 nodes with bundle "article" that contain the word "Test" into the body field
    $result_node = EC::entity($connection, new Model\Node(), 'article')
        ->load()
        ->select()
        ->fieldCondition('body', 'value', '%Test%', 'LIKE')
        ->range(0, 5)
        ->fetchAll();

    // Search the user with UID = 1
    $result_user = EC::entity($connection, new Model\Users(), 'user')
        ->load()
        ->select()
        ->propertyCondition('uid', 1)
        ->fetch();

```

### Insert

[](#insert)

```
use \DrupalHeadless\Database\Database;
use \DrupalHeadless\Entity\EntityController as EC;
use \DrupalHeadless\Entity\Model;

// Set connection info
Database::addConnectionInfo('default', 'default', [
    'driver'    => 'mysql',
    'database'  => 'drupal',
    'username'  => 'root',
    'password'  => 'root',
    'host'      => '127.0.0.1',
    'prefix'    => 'drupal_'
]);

$connection = Database::getConnection('default', 'default');

$entity = EC::entity($connection, new Model\Node(), 'article')->load();

// Load entity node and bundle "article" which "title" is equal to "This is a test"
$result_node = $entity->propertyCondition('title', 'This is test')->fetch();

// Insert into the custom/dynamic field the value "myvideo" with delta 0
$entity = $entity->insertFieldset('field_videoid', $result_node->nid, ['value' => 'myvideo'], 0);

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4caf72b4d969cfb8cdfbdc1d594c85b51c9316caf76b80aa0f9de7e3736cf59f?d=identicon)[juanparati](/maintainers/juanparati)

---

Top Contributors

[![juanparati](https://avatars.githubusercontent.com/u/835173?v=4)](https://github.com/juanparati "juanparati (25 commits)")

### Embed Badge

![Health badge](/badges/drupalheadless-database/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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