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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form