改进Model类的__isset方法

This commit is contained in:
thinkphp
2016-07-06 16:19:16 +08:00
parent f84af6b8fe
commit daba31339e

View File

@@ -1294,6 +1294,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/ */
public function __isset($name) public function __isset($name)
{ {
try {
if (array_key_exists($name, $this->data)) { if (array_key_exists($name, $this->data)) {
return true; return true;
} elseif ($this->getAttr($name)) { } elseif ($this->getAttr($name)) {
@@ -1301,6 +1302,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
} else { } else {
return false; return false;
} }
} catch (InvalidArgumentException $e) {
return false;
}
} }
/** /**