> 1067 - Invalid default value for 'begin_time'
时间: 2023-12-25 21:25:58 浏览: 26
这个错误通常是因为 MySQL 版本不兼容导致的。在 MySQL 5.7.5 之前,datetime 类型的字段默认值不能为 NULL,必须指定一个默认值。可以尝试将默认值改为当前时间戳,例如:
```
begin_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
```
如果你使用的是 MySQL 5.7.5 或更高版本,可以将 sql_mode 设置为 NO_ZERO_IN_DATE,NO_ZERO_DATE,例如:
```
SET sql_mode='NO_ZERO_IN_DATE,NO_ZERO_DATE';
```
相关问题
gui_mainfcn.m 具体·代码
`gui_mainfcn.m` 是一个 MATLAB GUI 应用程序的主函数文件,其中包含 MATLAB 自动生成的代码和用户自定义的代码。以下是一个简单的示例:
```
function varargout = mygui(varargin)
% MYGUI MATLAB code for mygui.fig
% MYGUI, by itself, creates a new MYGUI or raises the existing
% singleton*.
%
% H = MYGUI returns the handle to a new MYGUI or the handle to
% the existing singleton*.
%
% MYGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MYGUI.M with the given input arguments.
%
% MYGUI('Property','Value',...) creates a new MYGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before mygui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mygui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help mygui
% Last Modified by GUIDE v2.5 16-Aug-2021 10:24:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mygui_OpeningFcn, ...
'gui_OutputFcn', @mygui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before mygui is made visible.
function mygui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to mygui (see VARARGIN)
% Choose default command line output for mygui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mygui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mygui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% User-defined code
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% User-defined code
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% User-defined code
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% User-defined code
```
这段代码包含了 GUI 的初始化、回调函数和用户自定义代码。其中,`mygui_OpeningFcn` 是 GUI 初始化函数,`pushbutton1_Callback`、`pushbutton2_Callback` 和 `pushbutton3_Callback` 是三个按钮的回调函数,`axes1_CreateFcn` 是用于创建一个图形对象的函数。
monaco-editor配置代码高亮
Monaco Editor 是一个基于 Web 的代码编辑器,它提供了丰富的 API 和功能,同时也支持自定义主题和语法高亮。要配置代码高亮,你需要做以下几步:
1. 安装 monaco-editor 包
你可以通过 npm 或 yarn 安装 monaco-editor 包:
```
npm install monaco-editor
```
或者
```
yarn add monaco-editor
```
2. 引入 monaco-editor 样式文件
在你的 HTML 文件中引入 monaco-editor 的样式文件:
```html
<link rel="stylesheet" href="https://unpkg.com/monaco-editor@0.22.3/min/vs/editor/editor.main.css">
```
3. 引入语言定义文件
Monaco Editor 不会自动加载语言定义文件,你需要手动加载。你可以在这里找到所有支持的语言和它们的语言定义文件:https://github.com/microsoft/monaco-languages
例如,如果你想要支持 JavaScript 语言,你需要加载以下文件:
```html
<script src="https://unpkg.com/monaco-editor@0.22.3/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'https://unpkg.com/monaco-editor@0.22.3/min/vs' }});
require(['vs/editor/editor.main'], function() {
monaco.languages.register({ id: 'javascript' });
monaco.languages.setMonarchTokensProvider('javascript', {
tokenizer: {
root: [
[/\b(function)(\s+)([a-z$][\w$]*)/, ['keyword', null, 'function']],
[/[a-z$][\w$]*/, 'identifier'],
[/\s+/, 'white'],
[/[{}()\[\]]/, '@brackets'],
[/[=><!~?&|+\-*\/%]/, 'operator'],
[/\d+/, 'number'],
[/"([^"\\]|\\.)*$/, 'string.invalid'],
[/"/, 'string', '@string']
]
}
});
monaco.editor.create(document.getElementById('container'), {
value: 'function hello() {\n console.log("Hello world!");\n}',
language: 'javascript'
});
});
</script>
```
4. 自定义主题
你可以在 monaco-editor 中使用自定义主题。你可以在这里找到所有支持的主题:https://github.com/microsoft/vscode/tree/master/extensions/theme-defaults/themes
例如,如果你想要使用 VS Code 的 Dark+ 主题,你需要加载以下文件:
```html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/styles/vs2015.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@monaco-editor/react@3.8.0/min/vs/editor/editor.main.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@monaco-editor/react@3.8.0/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'https://cdn.jsdelivr.net/npm/@monaco-editor/react@3.8.0/min/vs' }});
require(['vs/editor/editor.main'], function() {
const theme = 'vs-dark-plus';
// 加载主题样式文件
fetch(`https://cdn.jsdelivr.net/npm/@monaco-editor/react@3.8.0/min/vs/editor/editor.${theme}.min.css`)
.then(res => res.text())
.then(css => {
const style = document.createElement('style');
style.innerHTML = css;
document.head.appendChild(style);
});
// 加载语言定义文件和代码高亮样式文件
Promise.all([
fetch('https://cdn.jsdelivr.net/npm/@monaco-editor/react@3.8.0/min/vs/basic-languages/javascript/javascript.min.js').then(res => res.text()),
fetch('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/languages/javascript.min.js').then(res => res.text())
])
.then(([jsLangDef, jsHighlightDef]) => {
monaco.languages.register({ id: 'javascript' });
monaco.languages.setMonarchTokensProvider('javascript', {
tokenizer: {
root: [
[/\b(function)(\s+)([a-z$][\w$]*)/, ['keyword', null, 'function']],
[/[a-z$][\w$]*/, 'identifier'],
[/\s+/, 'white'],
[/[{}()\[\]]/, '@brackets'],
[/[=><!~?&|+\-*\/%]/, 'operator'],
[/\d+/, 'number'],
[/"([^"\\]|\\.)*$/, 'string.invalid'],
[/"/, 'string', '@string']
]
}
});
monaco.editor.defineTheme(theme, {
base: 'vs-dark',
inherit: true,
rules: [
{ token: 'delimiter', foreground: '569cd6' },
{ token: 'keyword', foreground: 'c586c0' },
{ token: 'identifier', foreground: '9cdcfe' },
{ token: 'number', foreground: 'b5cea8' },
{ token: 'string', foreground: 'ce9178' },
{ token: 'operator', foreground: 'd4d4d4' }
]
});
monaco.editor.create(document.getElementById('container'), {
value: 'function hello() {\n console.log("Hello world!");\n}',
language: 'javascript',
theme
});
hljs.registerLanguage('javascript', () => ({
keywords: {
keyword: 'break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import interface in instanceof let new null package private protected public return static super switch this throw true try typeof var void while with yield',
literal: 'null undefined true false NaN Infinity'
},
contains: [
hljs.HASH_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
{
beginKeywords: 'function', end: /\{/, excludeEnd: true,
contains: [
hljs.TITLE_MODE,
{
className: 'params',
begin: /\(/, end: /\)/,
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
hljs.TITLE_MODE
]
}
]
},
{
beginKeywords: 'class', end: /\{/, excludeEnd: true,
contains: [
hljs.TITLE_MODE,
{
beginKeywords: 'extends',
endsWithParent: true,
contains: [hljs.TITLE_MODE]
}
]
}
]
}));
hljs.initHighlightingOnLoad();
});
});
</script>
```
以上代码中的 `theme` 变量指定了要使用的主题,你可以自由更改。`monaco.editor.defineTheme` 方法用于定义主题,它接受一个对象作为参数,该对象包含了主题的配置信息。在这个例子中,我们重写了一些规则来更改颜色方案。
5. 创建编辑器实例
最后,你需要创建一个编辑器实例,并指定要使用的语言和主题:
```html
<div id="container" style="height: 400px;"></div>
<script>
monaco.editor.create(document.getElementById('container'), {
value: 'function hello() {\n console.log("Hello world!");\n}',
language: 'javascript',
theme: 'vs-dark-plus'
});
</script>
```
以上就是在 monaco-editor 中配置语法高亮的基本步骤。你可以按照以上方式配置任意支持的语言和主题。