0

Database Admin menu So 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 a challenge sometimes.

1 Answer 1

0

Can use Magento\Framework\App\ResourceConnection

Example:

use Magento\Framework\App\ResourceConnection;

class Test
{
    private $resource;
    
    public function __construct(
        ResourceConnection $resource
    ) {
        $this->resource = $resource;
    }
    
    public function save()
    {
        $dataset = [
            'slider_id' => 1,
            'banner_id' => 2,
        ];

        $connection = $this->resource->getConnection();
        $tableName = $connection->getTableName('muffin_bannerslider');
        try {
            $connection->insert($tableName, $dataset);
        } catch (\Exception $e) {
            $this->logger->critical($e->getMessage());
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.