改名
This commit is contained in:
+14
-13
@@ -5,6 +5,8 @@
|
|||||||
* Date: 2018/3/30 0030
|
* Date: 2018/3/30 0030
|
||||||
* Time: 14:09
|
* Time: 14:09
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
namespace Database;
|
namespace Database;
|
||||||
|
|
||||||
@@ -27,23 +29,23 @@ class Connection extends Component
|
|||||||
const TRANSACTION_COMMIT = 'transaction::commit';
|
const TRANSACTION_COMMIT = 'transaction::commit';
|
||||||
const TRANSACTION_ROLLBACK = 'transaction::rollback';
|
const TRANSACTION_ROLLBACK = 'transaction::rollback';
|
||||||
|
|
||||||
public $id = 'db';
|
public string $id = 'db';
|
||||||
public $cds = '';
|
public string $cds = '';
|
||||||
public $password = '';
|
public string $password = '';
|
||||||
public $username = '';
|
public string $username = '';
|
||||||
public $charset = 'utf-8';
|
public string $charset = 'utf-8';
|
||||||
public $tablePrefix = '';
|
public string $tablePrefix = '';
|
||||||
|
|
||||||
public $timeout = 1900;
|
public int $timeout = 1900;
|
||||||
|
|
||||||
public $maxNumber = 200;
|
public int $maxNumber = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* enable database cache
|
* enable database cache
|
||||||
*/
|
*/
|
||||||
public $enableCache = false;
|
public bool $enableCache = false;
|
||||||
public $cacheDriver = 'redis';
|
public string $cacheDriver = 'redis';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@@ -54,10 +56,9 @@ class Connection extends Component
|
|||||||
* 'password' => 'root'
|
* 'password' => 'root'
|
||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
public $slaveConfig = [];
|
public array $slaveConfig = [];
|
||||||
|
|
||||||
/** @var Schema $_schema */
|
private ?Schema $_schema = null;
|
||||||
private $_schema = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+9
-24
@@ -6,8 +6,12 @@
|
|||||||
* Time: 01:04
|
* Time: 01:04
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Snowflake\Core;
|
namespace Snowflake\Core;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JSON
|
* Class JSON
|
||||||
* @package Snowflake\Snowflake\Core
|
* @package Snowflake\Snowflake\Core
|
||||||
@@ -16,41 +20,22 @@ class JSON
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param string|array|mixed $data
|
||||||
* @return false|string
|
* @return false|string
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function encode($data)
|
public static function encode(string|array|object $data)
|
||||||
{
|
{
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
return self::filter(ArrayAccess::toArray($data));
|
return json_encode(ArrayAccess::toArray($data));
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $data
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private static function filter($data)
|
|
||||||
{
|
|
||||||
array_walk_recursive($data, function ($value, $key) use ($data) {
|
|
||||||
if (!is_numeric($value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (is_int(+$value)) {
|
|
||||||
$value = +$value;
|
|
||||||
}
|
|
||||||
$data[$key] = $value;
|
|
||||||
});
|
|
||||||
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
* @param bool $asArray
|
* @param bool $asArray
|
||||||
@@ -107,7 +92,7 @@ class JSON
|
|||||||
* @param $state
|
* @param $state
|
||||||
* @param $body
|
* @param $body
|
||||||
* @return false|int|string
|
* @return false|int|string
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function output($state, $body)
|
public static function output($state, $body)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user