dev-master
9999999-dev https://github.com/weierophinney/phlyql_resourceLibrary for persisting JSON resources in SQLite
BSD-2-Clause
The Requires
- php >=5.3.3
- zendframework/zend-math 2.*
json rest sqlite
Library for persisting JSON resources in SQLite
This is a "toy" library designed to make it easy to prototype persistence for RESTful APIs. It essentially allows you to create a SQLite database with the following columns:, (*1)
The easiest way to install is via Composer. Download
the composer installer, and create a composer.json
file as follows:, (*2)
{ "minimum-stability": "dev", "require": { "phly/sqlite-resource": "dev-master" } }
Then run composer install
., (*3)
A schema is available in schema.sqlite.sql. Essentially:, (*4)
CREATE TABLE IF NOT EXISTS collection ( id CHARACTER(32) PRIMARY KEY, data BLOB NOT NULL );
Alter it as you see fit to change the table name., (*5)
In order to instantiate Phly\SqliteResource\SqliteResource
, you will need an
instance of PDO. Typical instantiation will look like this:, (*6)
use PDO; use Phly\SqliteResource\SqliteResource; $pdo = new PDO('sqlite:/path/to/database.db'); $resource = new SqliteResource($pdo, 'table-name');
The API supports the following operations:, (*7)
$data
with the record that
already exists in the database identified by $id
and saves it. The merged
resource is returned.$id
with
the $data
. Returns the resource.$id
.Do not use this in production. Use a document database, or a relational database with a real schema that maps to the fields in your resources., (*8)
This module is licensed using the BSD 2-Clause License:, (*9)
Copyright (c) 2013, Matthew Weier O'Phinney All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Library for persisting JSON resources in SQLite
BSD-2-Clause
json rest sqlite