Any way to get all fillable fields by simple SQL query for Laravel Model?












-1















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.










share|improve this question




















  • 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















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.










share|improve this question




















  • 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








-1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












3 Answers
3






active

oldest

votes


















1














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






share|improve this answer































    0














    MySQL Query :



    SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
    FROM information_schema.columns
    WHERE table_name = 'my_table';


    enter image description here






    share|improve this answer































      -1














      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.






      share|improve this answer
























      • Note: that this answer was for the original question that was subsequently rewritten completely.

        – James Ray
        Jan 24 at 3:50











      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      1














      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






      share|improve this answer




























        1














        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






        share|improve this answer


























          1












          1








          1







          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






          share|improve this answer













          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 16 '17 at 4:36









          Alex KapustinAlex Kapustin

          1,221812




          1,221812

























              0














              MySQL Query :



              SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
              FROM information_schema.columns
              WHERE table_name = 'my_table';


              enter image description here






              share|improve this answer




























                0














                MySQL Query :



                SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
                FROM information_schema.columns
                WHERE table_name = 'my_table';


                enter image description here






                share|improve this answer


























                  0












                  0








                  0







                  MySQL Query :



                  SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
                  FROM information_schema.columns
                  WHERE table_name = 'my_table';


                  enter image description here






                  share|improve this answer













                  MySQL Query :



                  SELECT CONCAT('"',COLUMN_NAME,'",') as fillable
                  FROM information_schema.columns
                  WHERE table_name = 'my_table';


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 25 '18 at 12:17









                  Hasib KamalHasib Kamal

                  742617




                  742617























                      -1














                      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.






                      share|improve this answer
























                      • Note: that this answer was for the original question that was subsequently rewritten completely.

                        – James Ray
                        Jan 24 at 3:50
















                      -1














                      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.






                      share|improve this answer
























                      • Note: that this answer was for the original question that was subsequently rewritten completely.

                        – James Ray
                        Jan 24 at 3:50














                      -1












                      -1








                      -1







                      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.






                      share|improve this answer













                      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.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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



















                      • 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


















                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                      Calculate evaluation metrics using cross_val_predict sklearn

                      Insert data from modal to MySQL (multiple modal on website)