Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.
/ sql Public archive

SQL abstraction layer adapter to handle simple CRUD operations written in PHP and built on top of Doctrine/DBAL.

Notifications You must be signed in to change notification settings

soupmix/sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Soupmix

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality Code Coverage

Simple SQL abstraction layer adapter to handle CRUD operations written in PHP and built on top of Doctrine/DBAL. This library does not provide any ORM or ODM.

Installation

It's recommended that you use Composer to install Soupmix.

$ composer require soupmix/sql "~0.7"

This will install Soupmix and all required dependencies. Soupmix requires PHP 5.6.0 or newer.

Documentation

API Documentation: See details about the db adapters functions:

Usage

// Connect to 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"    => "[email protected]"      
];
$docs[] = [
    "full_name" => "Jack Doe",
    "age" => 38,
    "email"    => "[email protected]"
];

$docs[] = [
    "full_name" => "Jane Doe",
    "age" => 29,
    "email"    => "[email protected]"
];

foreach($docs as $doc){
    // insert user into database
    $sql_user_id = $sql->insert("users",$doc);
}
// get user data using id
$user_data = $sql->get('users', $sql_user_id);



// 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 = $sql->find("users", $filter);


Contribute

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

About

SQL abstraction layer adapter to handle simple CRUD operations written in PHP and built on top of Doctrine/DBAL.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages