error; } //自动时间戳 protected $autoWriteTimestamp = true; /** * 获取错误信息 * @param string $defaultMsg * @return string */ public static function getErrorInfo($defaultMsg = self::DEFAULT_ERROR_MSG) { return !empty(self::$errorMsg) ? self::$errorMsg : $defaultMsg; } /** * 查询一条数据是否存在 * @param $map * @param string $field * @return bool 是否存在 * @throws DbException */ public static function isExist($map, $field = ''): bool { $model = (new self); if (!is_array($map) && empty($field)) $field = $model->getPk(); $map = !is_array($map) ? [$field => $map] : $map; return 0 < $model->where($map)->count(); } }