2017 © Pedro PelĂĄez
 

library dbwrapper

Universal minimalist database wrapper

image

soluble/dbwrapper

Universal minimalist database wrapper

  • Friday, June 29, 2018
  • by belgattitude
  • Repository
  • 2 Watchers
  • 7 Stars
  • 1,206 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 2 % Grown

The README.md

soluble/dbwrapper

PHP 7.1+ Build Status codecov Scrutinizer Quality Score Latest Stable Version Total Downloads License, (*1)

Introduction

Minimalist (but universal) database wrapper to rule them all (and to not choose)., (*2)

Features

  • Provide a generic API for handling database access across various implementations.
  • Lightweight, framework adaptive and agnostic.
  • Natively supports mysqli, pdo_mysql, pdo_sqlite drivers.
  • Bridged implementations of zend-db, laravel and doctrine.
    • Access to Oracle, SQL-Server, PostgreSql,...
    • Allow to develop database portable libraries.
  • Adhere to soluble programming standards.

Requirements

  • PHP 7.1 optional ext-mysqli/PDO

For PHP 5.6+, 7.0+ or HHVM >= 3.9 look at version 1.3. For PHP < 5.6 take the 1.2 version, (*3)

Documentation

Installation

Instant installation via composer., (*4)

$ composer require soluble/dbwrapper

Quick start

Connection

Create an adapter from an existing Mysqli connection, (*5)

<?php

use Soluble\DbWrapper;

$conn = new \mysqli($hostname,$username,$password,$database);
$conn->set_charset($charset);

$adapter = DbWrapper\AdapterFactory::createAdapterFromResource($conn);

Querying database

Execute SQL, (*6)

<?php
$results = $adapter->query("select * from my_table");
foreach($results as $result) {
    echo $result['my_column'];
}

Get connection infos

Execute SQL, (*7)

<?php
$connection = $adapter->getConnection();
echo $connection->getCurrentSchema();
echo $connection->getHost();

$resource = $connection->getResource();

API methods

AdapterFactory

The DbWrapper\AdapterFactory allows to instanciate an Adapter from en existing connection link or resource., (*8)

Methods Return Comment
static createAdapterFromResource($resource) AdapterInterface From existing resource (mysqli, pdo)
static createAdapterFromDbal2($dbal) AdapterInterface From doctrine/dbal connection
static createAdapterFromCapsule5($capsule) AdapterInterface From Laravel connection
static createAdapterFromZendDb2($zend) AdapterInterface From zend-db connection

AdapterInterface

The DbWrapper\Adapter\AdapterInterface provides common operation on your database., (*9)

Methods Return Description
query($query) Resultset Iterable results DbWrapper\Result\Resultset
execute($query) void Execute command (set, ...)
quoteValue($value) string Quote value
getConnection() ConnectionInterface ConnectionInterface

Resultset

The DbWrapper\Result\Resultset is can be easily iterated through a simple foreach loop. Additionnaly you can call the following methods :, (*10)

Methods Return Description
count() int Count the number of results

ConnectionInterface

The DbWrapper\Connection\ConnectionInterface provides information about your connection, (*11)

Methods Return Description
getCurrentSchema() `string false`| Return current schema
getResource() mixed Return internal connection (pdo, mysqli...)
getHost() string Return server hostname or IP

Supported databases

Native

soluble/dbwrapper supports natively :, (*12)

Database PHP ext
Mysql mysqli, pdo_mysql
MariaDb mysqli, pdo_mysql
Sqlite pdo_sqlite

For examples, see the native drivers doc, (*13)

Userland implementations

Some of the supported databases can be (incomplete list) :, (*14)

| Database | Doctrine | Laravel | Zend | |------------|------------|---------|-----------| | Mysql | Yes | Yes | Yes | | MariaDb | Yes | Yes | Yes | | Sqlite | Yes | Yes | Yes | | Oracle | Yes | No | Yes | | Sqlserver | Yes | Yes | Yes | | Postgres | Yes | Yes | Yes | (...), (*15)

For examples, see the userland drivers doc, (*16)

Motivations

Initially the reason behind the development of soluble/dbwrapper was to get a reliable and lightweight library to abstract the PDO_mysql and mysqli driver interfaces., (*17)

Later on, while developing some libraries, I feel the need for something more framework agnostic that could still be integrated easily into any modern framework. The userland drivers idea was born., (*18)

Contributing

Contribution and pull request are more than welcome, see the contribution guide, (*19)

Coding standards

The Versions

29/06 2018

dev-master

9999999-dev http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • ext-pdo *
  • php ^5.6 || ^7.0

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

29/06 2018

1.3.3

1.3.3.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

18/01 2018

1.3.2

1.3.2.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

15/09 2017

1.3.1

1.3.1.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

12/08 2017

1.3.0

1.3.0.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

29/02 2016

0.11.0

0.11.0.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

29/02 2016

1.2.1

1.2.1.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

25/02 2016

0.10.2

0.10.2.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

25/02 2016

1.2.0

1.2.0.0 http://soluble.io

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

06/01 2016

1.1.0

1.1.0.0 https://github.com/belgattitude/soluble-dbwrapper

Universal minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.4.4|~7.0
  • ext-pdo *

 

The Development Requires

database laravel eloquent doctrine pdo dbal mysql zend-framework illuminate zend-db pdo_mysql

02/01 2016

1.0.0

1.0.0.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.4.4
  • ext-pdo *

 

database pdo mysql pdo_mysql

02/01 2016

0.10.1

0.10.1.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.4.4
  • ext-pdo *

 

database pdo mysql pdo_mysql

01/01 2016

0.10.0

0.10.0.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-pdo *

 

database pdo mysql pdo_mysql

01/01 2016

0.9.3

0.9.3.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-pdo *

 

database pdo mysql pdo_mysql

01/01 2016

0.9.2

0.9.2.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-mysqli *
  • ext-pdo *

 

database pdo mysql pdo_mysql

01/01 2016

0.9.1

0.9.1.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-mysqli *
  • ext-pdo *

 

database pdo mysql pdo_mysql

01/01 2016

0.9.0

0.9.0.0 https://github.com/belgattitude/soluble-dbwrapper

Extra minimalist database wrapper

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-mysqli *
  • ext-pdo *

 

database mysql pdo_mysql pdi