Magento 2: Insert and select operation (without model) in custom moduleAdmin module custom select not saveingdefinition path to shipping model when create custom shipping methodMagento 2 Create Custom modulehow insert data into database custom table using custom module in modelMagento 2 Custom Module Insert Data IssueMagento 2 - how to get custom model from custom moduleBest way to Insert multiple new rows for custom module inside foreach loopMagento 2 Custom Module Insert Data Issue not workingInsert, Update values in existing custom table and Select values from that table. Magento2How to Insert record in database-table through custom module in magento2

What is the difference between a game ban and a VAC ban in Steam?

Term for checking piece whose opponent daren't capture it

How do I truncate a csv file?

Is there any practical advantage to a parabolic reflector over a high-gain beam antenna?

Strange math syntax in old basic listing

Could IPv6 make NAT / port numbers redundant?

The qvolume of an integer

How can an eldritch abomination hide its true form in public?

Asking bank to reduce APR instead of increasing credit limit

Why is Colorado so different politically from nearby states?

Is having a hidden directory under /etc safe?

What's the most polite way to tell a manager "shut up and let me work"?

Are there regional foods in Westeros?

Opposite of "Squeaky wheel gets the grease"

Can you please explain this joke: "I'm going bananas is what I tell my bananas before I leave the house"?

How to properly maintain eye contact with people that have distinctive facial features?

Asking for something with different prices

The oldest tradition stopped before it got back to him

What are the problems in teaching guitar via Skype?

Why does the UK have more political parties than the US?

Is there a rule that prohibits us from using 2 possessives in a row?

Are academic associations obliged to comply with the US government?

California: "For quality assurance, this phone call is being recorded"

Orientable with respect to complex cobordism?



Magento 2: Insert and select operation (without model) in custom module


Admin module custom select not saveingdefinition path to shipping model when create custom shipping methodMagento 2 Create Custom modulehow insert data into database custom table using custom module in modelMagento 2 Custom Module Insert Data IssueMagento 2 - how to get custom model from custom moduleBest way to Insert multiple new rows for custom module inside foreach loopMagento 2 Custom Module Insert Data Issue not workingInsert, Update values in existing custom table and Select values from that table. Magento2How to Insert record in database-table through custom module in magento2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















Please give me any example or link for insert and select process without using model in custom module of Magento 2.










share|improve this question






























    4















    Please give me any example or link for insert and select process without using model in custom module of Magento 2.










    share|improve this question


























      4












      4








      4








      Please give me any example or link for insert and select process without using model in custom module of Magento 2.










      share|improve this question
















      Please give me any example or link for insert and select process without using model in custom module of Magento 2.







      magento2 module database






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 24 at 5:50









      Dhara Bhatti

      169112




      169112










      asked May 24 at 5:44









      manojimanoji

      7410




      7410




















          1 Answer
          1






          active

          oldest

          votes


















          1














          Try this,



          Object Manager :



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
          $connection = $resource->getConnection();
          $tableName = $resource->getTableName('employee'); //gives table name with prefix

          //Select Data from table
          $sql = "Select * FROM " . $tableName;
          $result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.

          //Insert Data into table
          $sql = "Insert Into " . $tableName . " (emp_id, emp_name, emp_code, emp_salary) Values ('','XYZ','ABD20','50000')";
          $connection->query($sql);

          //Update Data into table
          $sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
          $connection->query($sql);


          Di method :



          <?php
          protected $_resourceConnection;
          protected $_connection;
          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection
          )
          $this->_resourceConnection = $resourceConnection;

          public function getCollection()

          $selectData = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $query = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $collection = selectData->fetchAll($query);
          return $collection;

          public function insertQuery()
          $insertQuery = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $saveQuery = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $save = $insertQuery->fetchAll($query);

          }


          Hope this helps.






          share|improve this answer

























          • Thank you. I tried this code's It works Perfectly...

            – manoji
            May 24 at 6:08











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fmagento.stackexchange.com%2fquestions%2f275939%2fmagento-2-insert-and-select-operation-without-model-in-custom-module%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Try this,



          Object Manager :



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
          $connection = $resource->getConnection();
          $tableName = $resource->getTableName('employee'); //gives table name with prefix

          //Select Data from table
          $sql = "Select * FROM " . $tableName;
          $result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.

          //Insert Data into table
          $sql = "Insert Into " . $tableName . " (emp_id, emp_name, emp_code, emp_salary) Values ('','XYZ','ABD20','50000')";
          $connection->query($sql);

          //Update Data into table
          $sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
          $connection->query($sql);


          Di method :



          <?php
          protected $_resourceConnection;
          protected $_connection;
          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection
          )
          $this->_resourceConnection = $resourceConnection;

          public function getCollection()

          $selectData = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $query = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $collection = selectData->fetchAll($query);
          return $collection;

          public function insertQuery()
          $insertQuery = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $saveQuery = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $save = $insertQuery->fetchAll($query);

          }


          Hope this helps.






          share|improve this answer

























          • Thank you. I tried this code's It works Perfectly...

            – manoji
            May 24 at 6:08















          1














          Try this,



          Object Manager :



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
          $connection = $resource->getConnection();
          $tableName = $resource->getTableName('employee'); //gives table name with prefix

          //Select Data from table
          $sql = "Select * FROM " . $tableName;
          $result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.

          //Insert Data into table
          $sql = "Insert Into " . $tableName . " (emp_id, emp_name, emp_code, emp_salary) Values ('','XYZ','ABD20','50000')";
          $connection->query($sql);

          //Update Data into table
          $sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
          $connection->query($sql);


          Di method :



          <?php
          protected $_resourceConnection;
          protected $_connection;
          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection
          )
          $this->_resourceConnection = $resourceConnection;

          public function getCollection()

          $selectData = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $query = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $collection = selectData->fetchAll($query);
          return $collection;

          public function insertQuery()
          $insertQuery = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $saveQuery = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $save = $insertQuery->fetchAll($query);

          }


          Hope this helps.






          share|improve this answer

























          • Thank you. I tried this code's It works Perfectly...

            – manoji
            May 24 at 6:08













          1












          1








          1







          Try this,



          Object Manager :



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
          $connection = $resource->getConnection();
          $tableName = $resource->getTableName('employee'); //gives table name with prefix

          //Select Data from table
          $sql = "Select * FROM " . $tableName;
          $result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.

          //Insert Data into table
          $sql = "Insert Into " . $tableName . " (emp_id, emp_name, emp_code, emp_salary) Values ('','XYZ','ABD20','50000')";
          $connection->query($sql);

          //Update Data into table
          $sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
          $connection->query($sql);


          Di method :



          <?php
          protected $_resourceConnection;
          protected $_connection;
          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection
          )
          $this->_resourceConnection = $resourceConnection;

          public function getCollection()

          $selectData = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $query = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $collection = selectData->fetchAll($query);
          return $collection;

          public function insertQuery()
          $insertQuery = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $saveQuery = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $save = $insertQuery->fetchAll($query);

          }


          Hope this helps.






          share|improve this answer















          Try this,



          Object Manager :



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
          $connection = $resource->getConnection();
          $tableName = $resource->getTableName('employee'); //gives table name with prefix

          //Select Data from table
          $sql = "Select * FROM " . $tableName;
          $result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.

          //Insert Data into table
          $sql = "Insert Into " . $tableName . " (emp_id, emp_name, emp_code, emp_salary) Values ('','XYZ','ABD20','50000')";
          $connection->query($sql);

          //Update Data into table
          $sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
          $connection->query($sql);


          Di method :



          <?php
          protected $_resourceConnection;
          protected $_connection;
          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection
          )
          $this->_resourceConnection = $resourceConnection;

          public function getCollection()

          $selectData = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $query = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $collection = selectData->fetchAll($query);
          return $collection;

          public function insertQuery()
          $insertQuery = $this->_resourceConnection->getConnection();
          //Your custom sql query
          $saveQuery = "SELECT * FROM ( SELECT * FROM TABLE_NAME WHERE customer_id IN ( 0, 5 ) ORDER BY feed_id DESC ) AS t1 GROUP BY position limit 0,5";

          $save = $insertQuery->fetchAll($query);

          }


          Hope this helps.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 24 at 5:52

























          answered May 24 at 5:47









          Prathap GunasekaranPrathap Gunasekaran

          2,3531721




          2,3531721












          • Thank you. I tried this code's It works Perfectly...

            – manoji
            May 24 at 6:08

















          • Thank you. I tried this code's It works Perfectly...

            – manoji
            May 24 at 6:08
















          Thank you. I tried this code's It works Perfectly...

          – manoji
          May 24 at 6:08





          Thank you. I tried this code's It works Perfectly...

          – manoji
          May 24 at 6:08

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • 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%2fmagento.stackexchange.com%2fquestions%2f275939%2fmagento-2-insert-and-select-operation-without-model-in-custom-module%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?