g737a6b / toei
PHP library to integrate scattered events in RDB.
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/g737a6b/toei
Requires (Dev)
- phpunit/dbunit: ^4
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2021-12-01 10:08:16 UTC
README
PHP library to integrate scattered events in RDB.
Examples of use
RDB
-- Table "users" CREATE TABLE `users` (`id` INT, `name` TEXT, `created` DATETIME, `deleted` DATETIME); INSERT INTO `users` (`id`, `name`, `created`, `deleted`) VALUES (1, 'Suzuki', '2017-01-01 12:04:11', NULL), (2, 'Tanaka', '2017-01-21 09:57:48', '2017-03-20 18:03:30'), (3, 'Yoshida', '2017-02-04 20:47:25', NULL); -- Table "messages" CREATE TABLE `messages` (`sender` INT, `receiver` INT, `body` TEXT, `created` DATETIME); INSERT INTO `messages` (`sender`, `receiver`, `body`, `created`) VALUES (1, 2, 'Hi!', '2017-01-21 12:01:44'), (2, 3, 'Hi!', '2017-02-04 21:54:17'), (1, 3, 'Hi!', '2017-02-05 12:03:01'), (2, 1, 'Bye!', '2017-03-20 17:54:46'), (2, 3, 'Bye!', '2017-03-20 17:56:23');
config.json
{
"register": {
"table": "users",
"identifyBy": "id",
"sortBy": "created"
},
"withdraw": {
"table": "users",
"identifyBy": "id",
"sortBy": "deleted",
"condition": "created > '2000-01-01 00:00:00'"
},
"send_message": {
"table": "messages",
"identifyBy": "sender",
"sortBy": "created"
},
"recieve_message": {
"table": "messages",
"identifyBy": "receiver",
"sortBy": "created"
}
}
PHP
$config = json_decode(file_get_contents("config.json")); $Toei = new Toei\Toei($PDO, $config); $Toei->setId(2); $result = $Toei->project(true); // array(6) { // [0]=> // array(3) { // ["action"]=> // string(8) "register" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-01-21 09:57:48" // } // [1]=> // array(3) { // ["action"]=> // string(15) "recieve_message" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-01-21 12:01:44" // } // [2]=> // array(3) { // ["action"]=> // string(12) "send_message" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-02-04 21:54:17" // } // [3]=> // array(3) { // ["action"]=> // string(12) "send_message" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-03-20 17:54:46" // } // [4]=> // array(3) { // ["action"]=> // string(12) "send_message" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-03-20 17:56:23" // } // [5]=> // array(3) { // ["action"]=> // string(8) "withdraw" // ["id"]=> // string(1) "2" // ["time"]=> // string(19) "2017-03-20 18:03:30" // } // }
Installation
Composer
Add a dependency to your project's composer.json file.
{
"require": {
"g737a6b/toei": "*"
}
}
Development
Run tests
docker run -it --rm -v $(pwd):/app composer:1.8 run-script tests
License
Copyright (c) 2019 Hiroyuki Suzuki