mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
Model类的强制类型转换定义支持数组方式
This commit is contained in:
@@ -286,12 +286,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
* 数据写入 类型转换
|
* 数据写入 类型转换
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $value 值
|
* @param mixed $value 值
|
||||||
* @param string $type 要转换的类型
|
* @param string|array $type 要转换的类型
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function writeTransform($value, $type)
|
protected function writeTransform($value, $type)
|
||||||
{
|
{
|
||||||
if (strpos($type, ':')) {
|
if(is_array($type)){
|
||||||
|
$param = $type[1];
|
||||||
|
$type = $type[0];
|
||||||
|
}elseif (strpos($type, ':')) {
|
||||||
list($type, $param) = explode(':', $type, 2);
|
list($type, $param) = explode(':', $type, 2);
|
||||||
}
|
}
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@@ -365,12 +368,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
* 数据读取 类型转换
|
* 数据读取 类型转换
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $value 值
|
* @param mixed $value 值
|
||||||
* @param string $type 要转换的类型
|
* @param string|array $type 要转换的类型
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function readTransform($value, $type)
|
protected function readTransform($value, $type)
|
||||||
{
|
{
|
||||||
if (strpos($type, ':')) {
|
if(is_array($type)){
|
||||||
|
$param = $type[1];
|
||||||
|
$type = $type[0];
|
||||||
|
}elseif (strpos($type, ':')) {
|
||||||
list($type, $param) = explode(':', $type, 2);
|
list($type, $param) = explode(':', $type, 2);
|
||||||
}
|
}
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user