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