cancel
Showing results for 
Search instead for 
Did you mean: 

Add data to table without model

SOLVED

Add data to table without model

image.pngimage.pngSo i want to save slider_id and banner_id on muffin_bannerslider table with the purpose of tracking which slider belong to which banner and the position of the banner in a particular slider. But that table doesn't belong to any model then how should i do it . Also sorry if this topic already answered but Eng isn't my first language so to type the problem correctly to find the answer can be hard sometimes.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add data to table without model

Hi @Thaimeotsv57d7 ,

 

Please refer https://www.mageplaza.com/magento-2-module-development/how-to-create-crud-model-magento-2.html#step-...

 

You can refer from Step 2.

Or if you don't want to create model or dont want to follow Magento way then you can use sql queries like https://meetanshi.com/blog/run-direct-sql-query-in-magento-2/


But I am suggesting to follow default magento flow. Direct sql is not recommended.

 

 

Problem Solved? Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

View solution in original post

2 REPLIES 2

Re: Add data to table without model

Hi @Thaimeotsv57d7 ,

 

Please refer https://www.mageplaza.com/magento-2-module-development/how-to-create-crud-model-magento-2.html#step-...

 

You can refer from Step 2.

Or if you don't want to create model or dont want to follow Magento way then you can use sql queries like https://meetanshi.com/blog/run-direct-sql-query-in-magento-2/


But I am suggesting to follow default magento flow. Direct sql is not recommended.

 

 

Problem Solved? Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

Re: Add data to table without model

The thing is that table use composite primary key and magento 2 doesn't support it in model that's why i have to look for another solution.