nia/sql-operation

Component which contains simple CRUD operations using the `nia/sql-adapter` component.

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.2 2018-12-10 17:55 UTC

This package is not auto-updated.

Last update: 2022-03-16 11:58:50 UTC


README

Component which contains simple CRUD operations using the nia/sql-adapter component.

Installation

Require this package with Composer.

composer require nia/sql-operation

Tests

To run the unit test use the following command:

$ cd /path/to/nia/component/
$ phpunit --bootstrap=vendor/autoload.php tests/

How to use

The following sample shows you how to use the classes for simple CRUD operations.

// create usert
$operation = new InsertOperation($writingAdapter);
$id = $operation->insert('user', [
    'email' => 'foo@bar.baz',
    'password' => password_hash($password, PASSWORD_DEFAULT)
]);

// update user (change email address)
$operation = new UpdateOperation($writingAdapter);
$operation->update('user', $id, [
    'email' => 'faz@baz.boo'
]);

// fetch user
$operation = new FetchOperation($readingAdapter);
$user = $operation->fetch('user', $id);

// delete user
$operation = new UpdateOperation($writingAdapter);
$operation->delete('user', $id);