mirror of
https://github.com/kvazar-network/index-php.git
synced 2025-01-22 12:54:15 +00:00
add int, float data types, change codes
This commit is contained in:
parent
7fed49b563
commit
32fad62e38
@ -21,15 +21,17 @@ class Manticore
|
|||||||
private const OP_DUP = 400;
|
private const OP_DUP = 400;
|
||||||
private const OP_NOP = 500;
|
private const OP_NOP = 500;
|
||||||
|
|
||||||
private const TYPE_TEXT = 100;
|
private const TYPE_NULL = 0;
|
||||||
private const TYPE_BIN = 200;
|
private const TYPE_BOOL = 1;
|
||||||
private const TYPE_JSON = 300;
|
private const TYPE_STRING = 100;
|
||||||
private const TYPE_XML = 400;
|
private const TYPE_BIN = 110;
|
||||||
private const TYPE_BASE_64 = 500;
|
private const TYPE_JSON = 120;
|
||||||
private const TYPE_BOOL = 600;
|
private const TYPE_XML = 130;
|
||||||
private const TYPE_NULL = 700;
|
private const TYPE_BASE_64 = 140;
|
||||||
private const TYPE_ARRAY = 800;
|
private const TYPE_INT = 200;
|
||||||
private const TYPE_OBJECT = 900;
|
private const TYPE_FLOAT = 210;
|
||||||
|
private const TYPE_ARRAY = 300;
|
||||||
|
private const TYPE_OBJECT = 400;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
?string $name = 'kvazar',
|
?string $name = 'kvazar',
|
||||||
@ -124,7 +126,7 @@ class Manticore
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
// Manticore can store text data only, convert non-string types to Base64
|
// Manticore can store text data only, convert non-string types to Base64
|
||||||
if (self::TYPE_TEXT !== $typeKey = $this->_type($key))
|
if (self::TYPE_STRING !== $typeKey = $this->_type($key))
|
||||||
{
|
{
|
||||||
if (false === $key = json_encode($key))
|
if (false === $key = json_encode($key))
|
||||||
{
|
{
|
||||||
@ -132,7 +134,7 @@ class Manticore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::TYPE_TEXT !== $typeValue = $this->_type($value))
|
if (self::TYPE_STRING !== $typeValue = $this->_type($value))
|
||||||
{
|
{
|
||||||
if (false === $value = json_encode($value))
|
if (false === $value = json_encode($value))
|
||||||
{
|
{
|
||||||
@ -215,7 +217,7 @@ class Manticore
|
|||||||
foreach ($search->get() as $record)
|
foreach ($search->get() as $record)
|
||||||
{
|
{
|
||||||
// Raw data stored as JSON encoded string
|
// Raw data stored as JSON encoded string
|
||||||
if ($record->get('key_type') === self::TYPE_TEXT)
|
if ($record->get('key_type') === self::TYPE_STRING)
|
||||||
{
|
{
|
||||||
$key = $record->get('key');
|
$key = $record->get('key');
|
||||||
}
|
}
|
||||||
@ -227,7 +229,7 @@ class Manticore
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($record->get('value_type') === self::TYPE_TEXT)
|
if ($record->get('value_type') === self::TYPE_STRING)
|
||||||
{
|
{
|
||||||
$value = $record->get('value');
|
$value = $record->get('value');
|
||||||
}
|
}
|
||||||
@ -310,6 +312,12 @@ class Manticore
|
|||||||
{
|
{
|
||||||
switch (true)
|
switch (true)
|
||||||
{
|
{
|
||||||
|
case is_int($value):
|
||||||
|
return self::TYPE_INT;
|
||||||
|
|
||||||
|
case is_float($value):
|
||||||
|
return self::TYPE_FLOAT;
|
||||||
|
|
||||||
case is_bool($value):
|
case is_bool($value):
|
||||||
return self::TYPE_BOOL;
|
return self::TYPE_BOOL;
|
||||||
|
|
||||||
@ -335,7 +343,7 @@ class Manticore
|
|||||||
return self::TYPE_XML;
|
return self::TYPE_XML;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return self::TYPE_TEXT;
|
return self::TYPE_STRING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user