vuebix / tarantool
PHP Tarantool adapter for Bitrix.
dev-master
2018-01-28 23:32 UTC
Requires
- php: >=7.1
- ext-tarantool: *
This package is auto-updated.
Last update: 2024-03-29 03:50:43 UTC
README
This version of client requires Tarantool 1.8.2 or above and PECL PHP driver for Tarantool
Note
This library is an example of integration Tarantool with Bitrix.
Strongly NOT RECOMMEND to use on production environment
Installation
The recommended way to install the library is through Composer:
$ composer require vuebix/tarantool:@dev
Bitrix settings
Add new connection to /bitrix/.settings.php
'tarantool' =>
array (
'className' => '\\Vuebix\\DB\\TarantoolConnection',
'port': 3301,
'host' => '<tarantool>',
'login' => '<login>',
'password' => '<password>',
'sid' => 'tarantool',
),
Bitrix ORM entity
<?php
namespace Test{
use Bitrix\Main\Entity;
class DemoTable extends Entity\DataManager{
public static function getConnectionName(){
return 'tarantool';
}
public static function getTableName(){
return 'table';
}
public static function getMap(){
return [
new Entity\IntegerField('ID', [
'primary' => true,
'autocomplete' => true
]),
new Entity\StringField('NAME'),
];
}
}
}
Usage
<?php
// Get All records
$result = \Test\DemoTable::getList()->fetchAll();
var_dump($result);
// Get record
$result = \Test\DemoTable::getById($id)->fetch();
var_dump($result);
// Add new record
$result = \Test\DemoTable::add($data);
var_dump($result->isSuccess());
// Update record
\Test\DemoTable::update($id, ['NAME' => $name]);
var_dump($result->isSuccess());
// Delete record
$result = \Test\DemoTable::delete($id);
var_dump($result->isSuccess());
License
The library is released under the MIT License. See the bundled LICENSE file for details.