PHPackages                             skyfirephp/db - 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. skyfirephp/db

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

skyfirephp/db
=============

Stash Queries - PHP SQL library providing an easy, eloquent, and fluent yet expressive way to select, create, update, and delete SQL records.

29PHP

Since Feb 20Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/SkyfirePHP/DB)[ Packagist](https://packagist.org/packages/skyfirephp/db)[ RSS](/packages/skyfirephp-db/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Stash Queries
=============

[](#stash-queries)

> Stash Queries is an eloquent and expressive PHP library that simplifies database interactions.

It acts as a lightweight wrapper around PHP's native PDO (PHP Data Objects) extension, providing a fluent API to easily execute `SELECT`, `INSERT`, `UPDATE`, and `DELETE` operations using your actual SQL files. Originally developed as the *DB* service for the Skyfire PHP framework, this library is specifically designed as a native PDO replacement rather than a full Object-Relational Mapper (ORM).

*Note: Currently, Stash Queries supports MySQL and PostgreSQL databases. Support for additional database are up for request.*

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

[](#requirements)

- PHP 5.6 or higher
- `PDO_MYSQL` PHP extension

*(Note: PHP 5.6 is the minimum required version for security and modern language features.)*

Code Examples
-------------

[](#code-examples)

```
// setting the DB display encoding type (if needed)
FixCollation::charset('utf-8', FixCollation::TEXT_HTML);

// setting Database credentials
DB::define('stash_dir',   getcwd()); // or dirname(__FILE__)
DB::define('host',       'localhost');
DB::define('dbname',     'test_db1');
DB::define('dbuser',     'root');
DB::define('dbpassword', '');

// SQL select query (with prepare variables)
$prepare = array
(
    'label' => 'test'
);
$data = DB::select('get.HomeTextByLabel')->prepare($prepare);
var_dump($data);

// SQL simple select query
$data = DB::select('get.AllHomeTextData')->execute();
var_dump($data);

// raw SQL query (with prepare variables)
$data = DB::query('SELECT * FROM test WHERE data IS NOT NULL AND id > :count AND data != :text', array
(
    ':id'   => 10,
    ':text' => 'test'
))->execute();
var_dump($data);

// displays the prepare update statement in plain text (ideal for debugging queries)
$query = DB::update('PostfromTestById')->text($prepare);
echo $query;
```

Injections
----------

[](#injections)

You can securely inject dynamic variables directly into your queries (e.g., table names or column fields) when standard PDO bindings cannot be used:

```
$data = DB::select('get.fieldData.byId')->inject(array
(
    'field' => $data->field,
    'table' => $table_name
))->prepare(array('id' => (int) $record->id));
```

Persistent Connections
----------------------

[](#persistent-connections)

To enable persistent database connections for all queries, define the `persistent` configuration setting as follows:

```
DB::define('persistent', TRUE);
// DB::define('persistent', 'yes');
```

You can use either the boolean `TRUE` or the string `'yes'` to enable this feature.

Creating Query Folders
----------------------

[](#creating-query-folders)

If you are unsure whether your SQL query folders exist, you can call the following function to create them automatically. It returns `FALSE` if no directories were created, or an integer representing the number of directories created (e.g., `4`).

```
DB::createQueryDirectories();
```

**Note:** Ensure you place this function call after all `DB::define()` configurations.

Quickly Create a Database
-------------------------

[](#quickly-create-a-database)

You can conveniently create a new database if it doesn't already exist:

```
DB::createNotExist('database_name');
```

**Note:** Ensure you place this function call after all `DB::define()` configurations.

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

[](#installation)

**Manual Installation:**To include the library manually, simply require the `StashQueries.php` file in your project:

```
require_once 'DB/StashQueries.php';
```

**Via Composer:**Alternatively, you can install the library via Composer by adding `skyfirephp/db` to the `require` section of your `composer.json` file:

```
{
    "require": {
        "skyfirephp/db": "dev-master"
    }
}
```

License
-------

[](#license)

Stash Queries is open-sourced software licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright 2015-2017 [Travis van der Font](http://travisfont.com)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance52

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity12

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/e3b31f534c1ae8d1bf28f7ddbcac0c6a8348222f52864f2f56a21bb34fced4c7?d=identicon)[travisfont](/maintainers/travisfont)

---

Top Contributors

[![travisfont](https://avatars.githubusercontent.com/u/2539998?v=4)](https://github.com/travisfont "travisfont (70 commits)")

---

Tags

databaseinjectionmysqlpdopdo-replacementpdo-wrapperpersistent-connectionsphpqueriesquery-builderqueryingsqlstash-queriesstash-query

### Embed Badge

![Health badge](/badges/skyfirephp-db/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

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

8441.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)
