Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
779e20b7
Commit
779e20b7
authored
Nov 25, 2018
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db(php mysql): 编辑列名
parent
05c1bdc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
5 deletions
+56
-5
en.js
source/language/en.js
+6
-2
zh.js
source/language/zh.js
+6
-2
index.js
source/modules/database/php/index.js
+44
-1
No files found.
source/language/en.js
View file @
779e20b7
...
...
@@ -379,7 +379,7 @@ module.exports = {
showcreatetable
:
'Create Table SQL'
,
deltable
:
'Del Table'
,
addcolumn
:
'New Column'
,
editcolumn
:
'Edit Column'
,
editcolumn
:
'Edit Column
Name
'
,
delcolumn
:
'Del Column'
,
}
},
...
...
@@ -478,7 +478,11 @@ module.exports = {
},
editcolumn
:
{
title
:
"New column name"
,
invalid_tablename
:
"Column names should not contain special symbols"
,
get_column_type_error
:
"Get column type error"
,
success
:
'Update column name successfully'
,
error
:
'Failed to update column'
,
},
delcolumn
:
{
title
:
'Delete Column'
,
...
...
source/language/zh.js
View file @
779e20b7
...
...
@@ -380,7 +380,7 @@ module.exports = {
showcreatetable
:
'建表语句'
,
desctable
:
'查看表结构'
,
addcolumn
:
'添加列'
,
editcolumn
:
'编辑列'
,
editcolumn
:
'编辑列
名
'
,
delcolumn
:
'删除列'
,
}
},
...
...
@@ -479,7 +479,11 @@ module.exports = {
},
editcolumn
:
{
title
:
"输入新列名"
,
invalid_tablename
:
"列名不能带有特殊符号"
,
get_column_type_error
:
"获取列属性失败"
,
success
:
'修改列名成功'
,
error
:
'修改列名失败'
},
delcolumn
:
{
title
:
'删除列'
,
...
...
source/modules/database/php/index.js
View file @
779e20b7
...
...
@@ -1149,7 +1149,50 @@ class PHP {
let
dbname
=
new
Buffer
(
treeselect
.
split
(
'::'
)[
1
].
split
(
":"
)[
1
],
"base64"
).
toString
();
let
tablename
=
new
Buffer
(
treeselect
.
split
(
'::'
)[
1
].
split
(
":"
)[
2
],
"base64"
).
toString
();
let
columnname
=
new
Buffer
(
treeselect
.
split
(
'::'
)[
1
].
split
(
":"
)[
3
],
"base64"
).
toString
();
let
columntyperaw
=
this
.
tree
.
getSelectedItemText
();
let
columntype
=
null
;
var
ctypereg
=
new
RegExp
(
columnname
+
'
\\
s
\\
((.+?
\\
))
\\
)'
);
var
res
=
columntyperaw
.
match
(
ctypereg
);
if
(
res
.
length
==
2
)
{
columntype
=
res
[
1
];
}
if
(
columntype
==
null
)
{
toastr
.
error
(
LANG
[
'form'
][
'editcolumn'
][
'get_column_type_error'
],
LANG_T
[
'error'
]);
return
}
layer
.
prompt
({
value
:
columnname
,
title
:
`<i class="fa fa-file-code-o"></i>
${
LANG
[
'form'
][
'editcolumn'
][
'title'
]}
`
},(
value
,
i
,
e
)
=>
{
if
(
!
value
.
match
(
/^
[
a-zA-Z0-9_
]
+$/
)){
toastr
.
error
(
LANG
[
'form'
][
'editcolumn'
][
'invalid_tablename'
],
LANG_T
[
'error'
]);
return
}
layer
.
close
(
i
);
switch
(
this
.
dbconf
[
'type'
]){
case
"mysqli"
:
case
"mysql"
:
let
sql
=
`ALTER TABLE \`
${
dbname
}
\`.\`
${
tablename
}
\` CHANGE COLUMN \`
${
columnname
}
\` \`
${
value
}
\`
${
columntype
}
;`
;
this
.
manager
.
query
.
editor
.
session
.
setValue
(
sql
);
this
.
execSQLAsync
(
sql
,
(
res
,
err
)
=>
{
if
(
err
){
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'query'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
return
;
}
let
result
=
this
.
parseResult
(
res
[
'text'
]);
if
(
result
.
datas
[
0
][
0
]
==
'True'
){
toastr
.
success
(
LANG
[
'form'
][
'editcolumn'
][
'success'
],
LANG_T
[
'success'
]);
this
.
getColumns
(
id
,
dbname
,
tablename
);
}
else
{
toastr
.
error
(
LANG
[
'form'
][
'editcolumn'
][
'error'
],
LANG_T
[
'error'
]);
}
});
break
;
default
:
toastr
.
warning
(
LANG
[
'notsupport'
],
LANG_T
[
'warning'
]);
break
;
}
});
}
delColumn
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment