1

I'm getting this error when i try to save to my db an employee.

> Fatal error: Uncaught exception 'Exception' with message 'User Error:
> Some trans actions have not been committed or rolled back in
> C:\wamp64\www\magento1\vendor\
> magento\framework\DB\Adapter\Pdo\Mysql.php on line 3774' in
> C:\wamp64\www\magent
> o1\vendor\magento\framework\App\ErrorHandler.php:61 Stack trace:
> #0 [internal function]: Magento\Framework\App\ErrorHandler->handler(256, 'Some t
> ransactio...', 'C:\\wamp64\\www\\m...', 3774, Array)
> #1 C:\wamp64\www\magento1\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(3774
> ): trigger_error('Some transactio...', 256)
> #2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
> #3 {main}   thrown in C:\wamp64\www\magento1\vendor\magento\framework\App\ErrorHandler.php 
> on line 61

Here is the code

public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
        $setup->startSetup();

        $salesDepartment = $this->departmentFactory->create();
        $salesDepartment->setName('Sales');
        $salesDepartment->save();


        $employee = $this->employeeFactory->create();
        $employee->setDepartmentId($salesDepartment->getId())
            ->setEmail('john@sales.loc')
            ->setFirstName('John')
            ->setLastName('Doe')
            ->setServiceYears(3)
            ->setDob('1983-03-28')
            ->setSalary(3800.00)
            ->setVatNumber('GB123456789')
            ->setNote('Example note!')
            ->save();

        $setup->endSetup();
    }
}

The sales department has been saved to database though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.