soupmix / sql
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple SQL abstraction layer adapter to handle CRUD operations.
0.8.1
2017-07-23 16:09 UTC
Requires
- php: ^7.1
- doctrine/dbal: ^2.6
- soupmix/base: ^0.8
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpcov: ^4.0
- phpunit/phpunit: ~6.0
- satooshi/php-coveralls: ~1.0
README
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" => "johndoe@domain.com"
];
$docs[] = [
"full_name" => "Jack Doe",
"age" => 38,
"email" => "jackdoe@domain.com"
];
$docs[] = [
"full_name" => "Jane Doe",
"age" => 29,
"email" => "janedoe@domain.com"
];
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.