改进Model类 改进查询方法的SQL返回机制

This commit is contained in:
thinkphp
2016-06-12 22:47:08 +08:00
parent 6d0c3a633e
commit 00b0c0f229
4 changed files with 57 additions and 56 deletions

View File

@@ -292,8 +292,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected function writeTransform($value, $type)
{
if(is_array($type)){
$param = $type[1];
$type = $type[0];
list($type,$param) = $type;
}elseif (strpos($type, ':')) {
list($type, $param) = explode(':', $type, 2);
}
@@ -328,7 +327,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
case 'array':
$value = (array) $value;
case 'json':
$option = !empty($param) ? (intval)$param : JSON_UNESCAPED_UNICODE;
$option = !empty($param) ? (int)$param : JSON_UNESCAPED_UNICODE;
$value = json_encode($value, $option);
break;
case 'serialize':
@@ -374,8 +373,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected function readTransform($value, $type)
{
if(is_array($type)){
$param = $type[1];
$type = $type[0];
list($type,$param) = $type;
}elseif (strpos($type, ':')) {
list($type, $param) = explode(':', $type, 2);
}