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;
Please give me any example or link for insert and select process without using model in custom module of Magento 2.
magento2 module database
add a comment |
Please give me any example or link for insert and select process without using model in custom module of Magento 2.
magento2 module database
add a comment |
Please give me any example or link for insert and select process without using model in custom module of Magento 2.
magento2 module database
Please give me any example or link for insert and select process without using model in custom module of Magento 2.
magento2 module database
magento2 module database
edited May 24 at 5:50
Dhara Bhatti
169112
169112
asked May 24 at 5:44
manojimanoji
7410
7410
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
Thank you. I tried this code's It works Perfectly...
– manoji
May 24 at 6:08
add a comment |
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
);
);
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%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
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.
Thank you. I tried this code's It works Perfectly...
– manoji
May 24 at 6:08
add a comment |
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.
Thank you. I tried this code's It works Perfectly...
– manoji
May 24 at 6:08
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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%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
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