PHPackages                             ua1-labs/firesql - 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. ua1-labs/firesql

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

ua1-labs/firesql
================

Set your SQL database on fire by making it into a NoSQL database.

3.1.0(6y ago)61001MITPHPPHP &gt;7.1.0

Since May 16Pushed 6y ago5 watchersCompare

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

READMEChangelogDependencies (3)Versions (16)Used By (0)

FireSQL
=======

[](#firesql)

Set your SQL database on fire by making it into a NoSQL database!

**Table of Contents**

- [Getting Started](#getting-started)
- [Finding Objects](#finding-objects)
- [Advance Filtering](#advance-filtering)
- [API](#api)
- [FireBug Debug Panel](#fireBug-debug-panel)

Why Build NoSQL Funcitonality On a Relational Database?
-------------------------------------------------------

[](#why-build-nosql-funcitonality-on-a-relational-database)

The problem with most relationtional databases is the fact the their schemas get in the way of you being able to be swift in making changes to data structures. One of the major problems with maintaining relationtional databases is the fact that when you update schemas, you also need to issue, and manage, update scripts that could break systems if they are installed in the incorrect order or fail to run all together. It can become costly to maintain these systems. Projects like Wordpress have been able to circumvent these issues by mostly sticking to the same database data structures they have maintained since the beginning of the project. Over the years, Wordpress has had minimal changes to the data schema they were lauched with.

Getting Started
---------------

[](#getting-started)

### Installing FireSQL Into Your Project

[](#installing-firesql-into-your-project)

FireSQL is registered with [Composer](https://packagist.org/packages/ua1-labs/firesql). You may install it with composer using the command:

```
composer require ua1-labs/firesql

```

### Connecting To A Database

[](#connecting-to-a-database)

To connect FireSQL to your database, you have to provide a standard PHP PDO object at the instanciation of the FireSQL Class. **NOTE: Currently, the only two database types FireSQL supports is MySQL and SQLite.**

```
$pdo = new \PDO('sqlite:' . __DIR__ . '/demo.db');
$db = new \UA1Labs\Fire\Sql($pdo);

```

### Getting A Collection

[](#getting-a-collection)

At some point, you are going to want to interact with data in the database itself. Whether that is inserting, updating, deleting, or reading that data. In the concept of NoSQL or Non-Relationtional databases, we bundle objects together in what we call "collections." A collection is a place to store similar objects. Not that the object schema matters, when you store objects with a similar nature of schema, it will be a lot easier to query them.

When obtaining a collection, you do not need to register it. Simply by asking for it by name, FireSQL will return an object that will have access to the collection you are asking for.

```
$collection = $db->collection('CollectionName');

```

**Collection Options**

When asking for a collection, you have the ability to pass in options that will allow the collection to enable certain features for that collection.

```
$options = [
    'versionTracking' => true,
    'model' => 'MyCollectionModel'
];
$collection = $db->collection('CollectionName', $options);

```

*Available Options*

OptionDescriptionValue TypeDefault ValueversionTrackingTurns on version tracking for objects within the collection. So whenever an object is updated or deleted, there will always be a trail of all past values for the objects within the collection.booleanfalsemodelWill set the object type the collection represents. When you set this option, whenever you insert or update objects, if the object isn't of the type you set a SqlException will be thrown. Also, when you retrieve objects, you'll get back the appropriate object type.string or nullnull### Inserting Your First Object

[](#inserting-your-first-object)

When dealing with objects in FireSQL, you can insert any object in a collection. You don't have to worry about the schema of the object. When inserting an object into the collection, FireSQL will attempt to serialize the object as a JSON string and store that as the record. Each record is stored with other information as well and also an index that will allow us to later retrieve the object.

Inserting an object:

```
$vehicle = new Vehicle();
$vehicle->setMake('Honda');
$vehicle->setModel('CRV');
$vehicle->setType('SUV');

$insertedObject = $carCollection->insert($vehicle);

```

Please take note that `$insertedObject` is no longer an instance of `Vehicle`. Instead it is an instance of `stdClass` as FireSQL does not maintain the instance object. Rather, just the public data within the object.

Also, when an object is stored in the database, as a part of storing the object, there are 4 fields added to every object that will provide you with information about that object and how it is stored in the database.

```
$insertedObject->__id; // the unique ID the object was stored as
$insertedObject->__revision // the revision number of the object
$insertedObject->__updated // the datetime the object was updated
$insertedObject->__origin // the datetime the object was first stored in the database

```

### Updating an Object

[](#updating-an-object)

Updating an object is in essents the same process as inserting one. In fact, behind the scenes it uses the very same logic for both updating and inserting. The only difference, is that when you update, you provide an ID for which object you will be updating.

```
$updatedObject = $carCollection->update($id, $vehicle);

```

### Deleting an Object

[](#deleting-an-object)

Deleting objects is very easy. They are deleted by ID.

```
$collection->delete($id);

```

### Getting Object Count

[](#getting-object-count)

Finding Objects
---------------

[](#finding-objects)

The most complex part of FireSQL is actually getting objects back out of the database once you have inserted them. For the most part, most of your searches will be easy to implement. So with that in mind, we will first talk about the easy way to get records out of the database. We will then later on talk about how to use [Advance Filtering](#advance-filtering) to execute more complex searches.

**Object Indexing**

To achieve the ability to search through objects in a collection, every time an object in inserted or updated within the collection, FireSQL will index objects by first level public members. At this point, indexes provide the ability to search by simple comparisons. We do not have any intention to implement deep object indexing within FireSQL. A value is only indexable if it lives on the root level of the object and it is either a string, integer, null, or boolean. No other data types are currently supported.

**Get Object By ID**

This is the simplest way to get objects out of the database. By searching for them by the ID that you already know.

```
$object = $collection->find($id);

```

The above method call will return a single object from the database by the given ID. If the collection does not contain an object with the given ID, then `null` will be returned.

**Get Object By Simple Filter**

Simple filters were a concept created to allow users to pass in JSON strings that represent searches. These JSON string directly represent the objects we are trying to match.

*Direct Comparison*

If you would like to find all objects in a collection that have exact values the example below will give you an idea on how to do that. In the example, you will notice that we are asking for all objects that is the equivalent of `$obj->name = 'josh'`

```
$search = '{"name":"josh"}';
$objects = $collection->find($search);

```

*Other Comparison Types*

FireSQL simple filters also supports using other comparison types other than just direct comparison. In the example below, we want to retrieve all objects that contain a `$num` greater than 5.

```
$search = '{"num":">5"}';
$objects = $collection->find($search);

```

Supported Comparisons:

ComparisonExampleEqual{"name":"josh"} or {"name":"=josh"}Not Equal{"name":"&lt;&gt;josh"}Greater Than{"num":"&gt;5"}Greater Than or Equal To{"num":"&gt;=5"}Less Than{"num":"&lt;5"}Less Than or Equal To{"num":"&lt;=5"}*AND Logic*

Simple filters also supports AND logic where you can group together multiple comparisons. The example below will return all objects within the collection that have `$obj->name = 'josh'` and `$obj->num` is not equal to `5`.

```
$search = '{"name":"josh", "num":"5"}';
$objects = $collection->find($search);

```

*OR Logic*

OR Logic is just as simple as AND logic. With OR logic, you would just simple group comparisons within different objects. The example below will return a collection of objects who's name is set to "josh" or "steve".

```
$search = '[{"name":"josh"},{"name":"steve"}]';
$objects = $collection->find($search);

```

*Magic Filter Methods*

Built in the concept of simple filters is the ability to further manipulate the collection of objects before it gets returned to you. Below you will find each method and a description of how it will manipulate the collection set.

MethodDescriptionExamplelengthThis method sets the number of objects you want to be returned from the entire collection{"length": "100"}offsetThis method sets how we should offset the dataset by{"offset": "10"}orderThis method dictates which field the dataset will be ordered by{"order": "field"}reverseThis method will determine if the order should be reversed from its natural accending order{"reverse": true}

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Recently: every ~96 days

Total

15

Last Release

2302d ago

Major Versions

0.1.0 → 1.0.02018-06-08

1.4.1 → 2.0.02018-12-28

2.1.0 → 3.0.02019-11-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/011120e2cbda7f8b2ff3cc55ee097b334b2498d4887517d9ae36d91ebe76f7cc?d=identicon)[thebytebar](/maintainers/thebytebar)

---

Top Contributors

[![joshua-johnson-disney](https://avatars.githubusercontent.com/u/181119147?v=4)](https://github.com/joshua-johnson-disney "joshua-johnson-disney (4 commits)")

---

Tags

ormdbalsqlnosqlmongofirefirestudioua1labsua1-labsua1

### Embed Badge

![Health badge](/badges/ua1-labs-firesql/health.svg)

```
[![Health](https://phpackages.com/badges/ua1-labs-firesql/health.svg)](https://phpackages.com/packages/ua1-labs-firesql)
```

###  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)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k241.3M3.3k](/packages/doctrine-doctrine-bundle)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[sokil/php-mongo

PHP Object Document Mapper for MongoDB

239161.5k9](/packages/sokil-php-mongo)[creof/doctrine2-spatial

Doctrine2 multi-platform support for spatial types and functions

2763.3M11](/packages/creof-doctrine2-spatial)

PHPackages © 2026

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