改进代码

This commit is contained in:
thinkphp
2016-04-10 17:04:15 +08:00
parent dab21914d8
commit 522e6cf8bf

View File

@@ -618,7 +618,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if ($cache) { if ($cache) {
// 查找是否存在缓存 // 查找是否存在缓存
$name = basename(str_replace('\\', '/', get_called_class())); $name = basename(str_replace('\\', '/', static::class));
$guid = md5('model_' . $name . '_' . serialize($data)); $guid = md5('model_' . $name . '_' . serialize($data));
$result = Cache::get($guid); $result = Cache::get($guid);
if ($result) { if ($result) {
@@ -873,7 +873,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/ */
protected static function db() protected static function db()
{ {
$model = get_called_class(); $model = static::class;
if (!isset(self::$links[$model])) { if (!isset(self::$links[$model])) {
self::$links[$model] = Db::connect(static::$connection); self::$links[$model] = Db::connect(static::$connection);