2017 © Pedro Peláez
 

library base

Simple database abstraction layer adapters collection to handle CRUD operations.

image

soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  • Sunday, July 23, 2017
  • by mkorkmaz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 911 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 1 % Grown

The README.md

Soupmix

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Simple database abstraction layer adapters collection to handle CRUD operations written in PHP. This library does not provide any ORM or ODM., (*2)

Adapters

  • MongoDB: Exists
  • Elasticsearch: Exists
  • Couchbase: Planned
  • Doctrine DBAL: Exists ** MySQL ** PostgreSQL ** Microsoft SQL ** Oracle ** SQLite

Installation

This library contains only interface and abstract classes. To use with a database you have to install the package written for that database. i.e: soupmix/mongodb for MongoDB;, (*3)

It's recommended that you use Composer to install Soupmix., (*4)

$ composer require soupmix/base "~0.7"

This will install Soupmix and all required dependencies. Soupmix requires PHP 5.6.0 or newer., (*5)

Documentation

API Documentation: See details about the db adapters functions:, (*6)

Usage

// Connect to MongoDB Service
$adapter_config = [];
$adapter_config['db_name'] ='db_name';
$adapter_config['connection_string']="mongodb://127.0.0.1";
$adapter_config['options'] =[];
$config['db_name'] = $adapter_config['db_name];
$client = new \MongoDB\Client($adapter_config['connection_string'], $adapter_config['options']);
$m=new Soupmix\MongoDB($config, $client);

// Connect to Elasticsearch Service
$adapter_config             = [];
$adapter_config['db_name']  = 'indexname';
$adapter_config['hosts']    = ["127.0.0.1:9200"];
$adapter_config['options']  = [];
$config['db_name'] = $adapter_config['db_name];
$client = \Elasticsearch\ClientBuilder::create()->setHosts($adapter_config['hosts'])->build();
$e=new Soupmix\ElasticSearch($config, $client);

// Connect SQL Service 

$config = [
    'dbname'    => 'test',
    'user'      => 'root',
    'password'  => '',
    'host'      => '127.0.0.1',
    'port'      => 3306,
    'charset'   => 'utf8',
    'driver'    => 'pdo_mysql',
];
$client = \Doctrine\DBAL\DriverManager::getConnection($config);
$sql = new \Soupmix\SQL(['db_name'=>$config['dbname']], $client);


$docs = [];
$docs[] = [
    "full_name" => "John Doe",
      "age" => 33,
      "email"   => "johndoe@domain.com",
      "siblings"=> [
        "male"=> [
          "count"=> 1,
          "names"=> ["Jack"]
        ],
        "female"=> [
          "count" => 1,
          "names" =>["Jane"]
        ]      
      ]
];
$docs[] = [
    "full_name" => "Jack Doe",
      "age" => 38,
      "email"   => "jackdoe@domain.com",
      "siblings"=> [
        "male"=> [
          "count"=> 1,
          "names"=> ["John"]
        ],
        "female"=> [
          "count" => 1,
          "names" =>["Jane"]
        ]      
      ]
];

$docs[] = [
    "full_name" => "Jane Doe",
      "age" => 29,
      "email"   => "janedoe@domain.com",
      "siblings"=> [
        "male"=> [
          "count"=> 2,
          "names"=> ["Jack","John"]
        ],
        "female"=> [
          "count" => 0,
          "names" =>[]
        ]      
      ]
];

foreach($docs as $doc){
    // insert user into database
    $mongo_user_id = $m->insert("users",$doc);
    $es_user_id = $e->insert("users",$doc);

}
// get user data using id
$es_user_data = $e->get('users', "AVPHZO1DY8UxeHDGBhPT");


$filter = ['age_gte'=>0];
// update users' data that has criteria encoded in $filter
$set = ['is_active'=>1,'is_deleted'=>0];

$e->update("users",$)

$filter = ["siblings.male.count__gte"=>2];

//delete users that has criteria encoded in $filter
$e->delete('users', $filter);



// user's age lower_than_and_equal to 34 or greater_than_and_equal 36 but not 38
$filter=[[['age__lte'=>34],['age__gte'=>36]],"age__not"=>38];

//find users that has criteria encoded in $filter
$docs = $e->find("users", $filter);


Contribute

  • Open issue if found bugs or sent pull request.
  • Feel free to ask if you have any questions.

The Versions

23/07 2017

dev-master

9999999-dev https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php ~7.1

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

23/07 2017

0.8

0.8.0.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php ~7.1

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

24/07 2016

0.7.13

0.7.13.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

13/07 2016

0.7.12

0.7.12.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

13/07 2016

0.7.11

0.7.11.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

03/07 2016

0.7.10

0.7.10.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

03/07 2016

0.7.9

0.7.9.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

02/07 2016

0.7.8

0.7.8.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

02/07 2016

0.7.7

0.7.7.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

01/07 2016

0.7.6

0.7.6.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

01/07 2016

0.7.5

0.7.5.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

01/07 2016

0.7.4

0.7.4.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

30/06 2016

0.7.3

0.7.3.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

30/06 2016

0.7.2

0.7.2.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

30/06 2016

0.7.1

0.7.1.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

30/06 2016

0.7

0.7.0.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters microsoft sql server

28/06 2016

0.6

0.6.0.0 https://github.com/soupmix/base

Simple database abstraction layer adapters collection to handle CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database postgresql elasticsearch mysql sqlite oracle abstraction layer adapters sel server

27/06 2016

0.5.1

0.5.1.0 https://github.com/soupmix/base

Simple PHP database adapters to handle low level CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

mongodb database elasticsearch adapters

01/06 2016

0.1.1

0.1.1.0 https://github.com/soupmix/base

Simple PHP database adapters to handle low level CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

mongodb database elasticsearch adapters

01/06 2016

0.5

0.5.0.0 https://github.com/soupmix/base

Simple PHP database adapters to handle low level CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

mongodb database elasticsearch adapters

31/05 2016

0.1

0.1.0.0 https://github.com/soupmix/base

Simple PHP database adapters to handle low level CRUD operations.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

mongodb database elasticsearch adapters