Any way to get all fillable fields by simple SQL query for Laravel Model?
Laravel model contain two value,
protected $table = 'table_name';
protected $fillable = [
'field_name1',
'field_name2'
];
When there are many fields in a table. It's need more time to copy one by one from table and paste. Is there any shortcut way to get all fields name including " (quotation) by SQL query.
mysql
add a comment |
Laravel model contain two value,
protected $table = 'table_name';
protected $fillable = [
'field_name1',
'field_name2'
];
When there are many fields in a table. It's need more time to copy one by one from table and paste. Is there any shortcut way to get all fields name including " (quotation) by SQL query.
mysql
1
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17
add a comment |
Laravel model contain two value,
protected $table = 'table_name';
protected $fillable = [
'field_name1',
'field_name2'
];
When there are many fields in a table. It's need more time to copy one by one from table and paste. Is there any shortcut way to get all fields name including " (quotation) by SQL query.
mysql
Laravel model contain two value,
protected $table = 'table_name';
protected $fillable = [
'field_name1',
'field_name2'
];
When there are many fields in a table. It's need more time to copy one by one from table and paste. Is there any shortcut way to get all fields name including " (quotation) by SQL query.
mysql
mysql
edited Nov 25 '18 at 11:38
Hasib Kamal
asked Jul 16 '17 at 4:15
Hasib KamalHasib Kamal
742617
742617
1
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17
add a comment |
1
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17
1
1
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17
add a comment |
3 Answers
3
active
oldest
votes
No, there is no such command. You should use mysqldump
tool to do so.
Please also note that
CREATE TABLE table1 as SELECT * FROM table2;
It will create table with the same architecture, but without indexes, better to use:
CREATE TABLE table1 like table2;
INSERT INTO table1 SELECT * FROM table2;
For getting all tables you can use:
show tables
You may also need to copy views, trigers, events, functions
add a comment |
MySQL Query :
SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
FROM information_schema.columns
WHERE table_name = 'my_table';
add a comment |
I am not sure of your use case, but I would recommend mysqldump
With this you can dump your database into one SQL file and then reload it into the new database with:
mysqldump -u root -p password databaseName > /path/databaseName.sql
mysql -u root -p password newDatabaseName < /path/databaseName.sql
However, this requires that you use the command line, and have the new database created already.
Note: Using login credentials in the command line is not recommended.
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45124901%2fany-way-to-get-all-fillable-fields-by-simple-sql-query-for-laravel-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, there is no such command. You should use mysqldump
tool to do so.
Please also note that
CREATE TABLE table1 as SELECT * FROM table2;
It will create table with the same architecture, but without indexes, better to use:
CREATE TABLE table1 like table2;
INSERT INTO table1 SELECT * FROM table2;
For getting all tables you can use:
show tables
You may also need to copy views, trigers, events, functions
add a comment |
No, there is no such command. You should use mysqldump
tool to do so.
Please also note that
CREATE TABLE table1 as SELECT * FROM table2;
It will create table with the same architecture, but without indexes, better to use:
CREATE TABLE table1 like table2;
INSERT INTO table1 SELECT * FROM table2;
For getting all tables you can use:
show tables
You may also need to copy views, trigers, events, functions
add a comment |
No, there is no such command. You should use mysqldump
tool to do so.
Please also note that
CREATE TABLE table1 as SELECT * FROM table2;
It will create table with the same architecture, but without indexes, better to use:
CREATE TABLE table1 like table2;
INSERT INTO table1 SELECT * FROM table2;
For getting all tables you can use:
show tables
You may also need to copy views, trigers, events, functions
No, there is no such command. You should use mysqldump
tool to do so.
Please also note that
CREATE TABLE table1 as SELECT * FROM table2;
It will create table with the same architecture, but without indexes, better to use:
CREATE TABLE table1 like table2;
INSERT INTO table1 SELECT * FROM table2;
For getting all tables you can use:
show tables
You may also need to copy views, trigers, events, functions
answered Jul 16 '17 at 4:36
Alex KapustinAlex Kapustin
1,221812
1,221812
add a comment |
add a comment |
MySQL Query :
SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
FROM information_schema.columns
WHERE table_name = 'my_table';
add a comment |
MySQL Query :
SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
FROM information_schema.columns
WHERE table_name = 'my_table';
add a comment |
MySQL Query :
SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
FROM information_schema.columns
WHERE table_name = 'my_table';
MySQL Query :
SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
FROM information_schema.columns
WHERE table_name = 'my_table';
answered Nov 25 '18 at 12:17
Hasib KamalHasib Kamal
742617
742617
add a comment |
add a comment |
I am not sure of your use case, but I would recommend mysqldump
With this you can dump your database into one SQL file and then reload it into the new database with:
mysqldump -u root -p password databaseName > /path/databaseName.sql
mysql -u root -p password newDatabaseName < /path/databaseName.sql
However, this requires that you use the command line, and have the new database created already.
Note: Using login credentials in the command line is not recommended.
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
add a comment |
I am not sure of your use case, but I would recommend mysqldump
With this you can dump your database into one SQL file and then reload it into the new database with:
mysqldump -u root -p password databaseName > /path/databaseName.sql
mysql -u root -p password newDatabaseName < /path/databaseName.sql
However, this requires that you use the command line, and have the new database created already.
Note: Using login credentials in the command line is not recommended.
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
add a comment |
I am not sure of your use case, but I would recommend mysqldump
With this you can dump your database into one SQL file and then reload it into the new database with:
mysqldump -u root -p password databaseName > /path/databaseName.sql
mysql -u root -p password newDatabaseName < /path/databaseName.sql
However, this requires that you use the command line, and have the new database created already.
Note: Using login credentials in the command line is not recommended.
I am not sure of your use case, but I would recommend mysqldump
With this you can dump your database into one SQL file and then reload it into the new database with:
mysqldump -u root -p password databaseName > /path/databaseName.sql
mysql -u root -p password newDatabaseName < /path/databaseName.sql
However, this requires that you use the command line, and have the new database created already.
Note: Using login credentials in the command line is not recommended.
answered Jul 16 '17 at 4:21
James RayJames Ray
45110
45110
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
add a comment |
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
Note: that this answer was for the original question that was subsequently rewritten completely.
– James Ray
Jan 24 at 3:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45124901%2fany-way-to-get-all-fillable-fields-by-simple-sql-query-for-laravel-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have you tried backing up and restoring? dev.mysql.com/doc/refman/5.7/en/backup-methods.html
– Dijkgraaf
Jul 16 '17 at 4:17