0

I'm very new to magento 2.3, I'm facing some error maybe from DB side....

Here is my code:

/app/code/EC/Customimport/Controller/Adminhtml/Index/Import.php

<?php

namespace EC\Customimport\Controller\Adminhtml\Index;

use EC\Customimport\Model\CustomimportFactory;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;

class Import extends \Magento\Backend\App\Action
{
    protected $request;

    /**
     * @param Context $context
     */
    public function __construct(
        \Magento\Framework\App\Request\Http $request,
        Context $context,
        CustomimportFactory $modelCustomimportFactory
    ) {
        $this->request = $request;
        $this->modelCustomimportFactory = $modelCustomimportFactory;
        $this->resultFactory = $context->getResultFactory();
        parent::__construct($context);
    }

    public function execute(){
        ignore_user_abort(true);
        set_time_limit(0);

        $ids = $this->getRequest()->getParams('customimport_id'); 

            $model = $this->modelCustomimportFactory->create()->load($id);
            $model->import();

        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
        $resultRedirect->setPath('adminhtml/*/index');
        return $resultRedirect;

    }
}

ERROR:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s),
query was: 
SELECT `customimport`.* FROM `customimport` 
WHERE 
(`customimport`.`customimport_id`='true', '4', 'FrFt7XBKVOwNwaq2')
8
  • 1
    what is the (customimport.customimport_id='true', '4', 'FrFt7XBKVOwNwaq2')? Commented May 15, 2019 at 12:32
  • A query......... Commented May 15, 2019 at 12:34
  • I know, but customimport_id's value why like 'true', '4', 'FrFt7XBKVOwNwaq2'? Commented May 15, 2019 at 12:35
  • basically customimport is a table in my DB & customimport_id='4' Commented May 15, 2019 at 12:35
  • @RutveeSojitra don't know why its making a wrong query..... Commented May 15, 2019 at 12:37

1 Answer 1

0

Replace this line $ids = $this->getRequest()->getParams('customimport_id'); => $ids = $this->getRequest()->getParam('customimport_id');

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.