FireSql – API Documentation

UA1Labs\Fire\Sql

__construct(PDO $pdo)

The class constructor.

  • @param \PDO $pdo
  • @return void
<?php
$pdo = new \PDO('sqlite:' . __DIR__ . '/demo.db');
$db = new \UA1Labs\Fire\Sql($pdo);

public function collection($name, $options = null)

Returns a collection object that will allow you to interact with the collection data.

  • @param string $name The name of the collection
  • @param array $options The collection options
  • @return \UA1Labs\Fire\Sql\Collection

Available Options:

  • versionTracking (default: false) – Determines if the collection should turn on the version tracking feature for collection updates.
<?php
$collection = $db->collection('CollectionName');

\UA1Labs\Fire\Sql\Collection

__construct($name, Connector $connector, $options = null)

Creates an instance of a new collection.

  • @param string $name The name of the collection
  • @param \UA1Labs\Fire\Sql\Connector $connector The connection to the database
  • @param array $options An array of options

Available Options:

  • versionTracking (default: false) – Determines if the collection should turn on the version tracking feature for collection updates.

find($filter = null)

Returns a collection of objects that match the filter criteria.

  • @param string | null | \UA1Labs\Fire\Sql\Filter $filter
  • @return array
<?php
$objects = $collection->find('{}');

insert($object)

Inserts an object in the collection.

  • @param object $object
<?php
$collection->insert($myObject);

update($id, $object)

Updates an object in the collection.

  • @param string $id
  • @param object $object
$collection->insert($id, $myObject);

delete($id)

Deletes an object from the database.

  • @param string $id The ID of the object you want to delete
$collection->delete($id);

count($filter = null)

Returns the total number of objects in a collection.

  • @param string | null | \UA1Labs\Fire\Sql\Filter $filter
$count = $collection->count('{}');

Leave a comment

Leave a Reply