I am getting "Notice: Array to string conversion" errors since I changed a field in my table. I think I made a mistake in changing my entity (which was an integer before)
/**
* @var array
* @ORM\Column(type="array", nullable=false)
*/
protected $sector = array();
.
.
.
.
/**
* Set sector
*
* @param array $sector
* @return Promotion
*/
public function setSector($sector)
{
$this->sector = $sector;
return $this;
}
/**
* Get sector
*
* @return array
*/
public function getSector()
{
return $this->sector;
}
Stack Trace:
[1] Doctrine\DBAL\DBALException: An exception occurred while executing 'INSERT INTO promotions (articleid, name1, name2, suppliername, picture, datefrom, dateto, position, highlight, category, sector, adminid, entrydate, alterationdate, description, aktion_id, alternative, alternativetext) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["1234567", "IFM N\u00e4herungsschalter kapazitiv KI5023", null, "IFM", "image_5_1234567.jpg", "2015-04-15", "2015-05-22", 1, 2, "75", [2,4], 12429, "2015-05-04 09:47:20", "2015-05-04 09:47:20", "<p>test<\/p>", 1, null, null]:
Notice: Array to string conversion in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 138
at n/a
in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 47
at Doctrine\DBAL\DBALException::driverExceptionDuringQuery(object(ContextErrorException), 'INSERT INTO promotions (articleid, name1, name2, suppliername, picture, datefrom, dateto, position, highlight, category, sector, adminid, entrydate, alterationdate, description, aktion_id, alternative, alternativetext) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('1234567', 'IFM Näherungsschalter kapazitiv KI5023', null, 'IFM', 'image_5_1234567.jpg', '2015-04-15', '2015-05-22', '1', '2', '75', array('2', '4'), '12429', '2015-05-04 09:47:20', '2015-05-04 09:47:20', '<p>test</p>', '1', null, null))
in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 140
at Doctrine\DBAL\Statement->execute()
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 277
at Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts()
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 929
at Doctrine\ORM\UnitOfWork->executeInserts(object(ClassMetadata))
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 318
at Doctrine\ORM\UnitOfWork->commit(null)
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 355
at Doctrine\ORM\EntityManager->flush()
in /server/xyz/Symfony/src/xyz/ShopBundle/Controller/OfferWeekController.php line 305
at xyz\ShopBundle\Controller\OfferWeekController->offerweekAction(object(Request), '0')
in line
at call_user_func_array(array(object(OfferWeekController), 'offerweekAction'), array(object(Request), '0'))
in /server/xyz/Symfony/app/bootstrap.php.cache line 2770
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /server/xyz/Symfony/app/bootstrap.php.cache line 2744
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /server/xyz/Symfony/app/bootstrap.php.cache line 2874
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /server/xyz/Symfony/app/bootstrap.php.cache line 2175
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /server/xyz/Symfony/web/app_dev.php line 30
[2] Symfony\Component\Debug\Exception\ContextErrorException: Notice: Array to string conversion in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 138
at n/a
in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 138
at Symfony\Component\Debug\ErrorHandler->handle('8', 'Array to string conversion', '/server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php', '138', array('params' => null, 'logger' => object(LoggerChain)))
in line
at PDOStatement->execute(null)
in /server/xyz/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 138
at Doctrine\DBAL\Statement->execute()
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 277
at Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts()
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 929
at Doctrine\ORM\UnitOfWork->executeInserts(object(ClassMetadata))
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 318
at Doctrine\ORM\UnitOfWork->commit(null)
in /server/xyz/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 355
at Doctrine\ORM\EntityManager->flush()
in /server/xyz/Symfony/src/xyz/ShopBundle/Controller/OfferWeekController.php line 305
at xyz\ShopBundle\Controller\OfferWeekController->offerweekAction(object(Request), '0')
in line
at call_user_func_array(array(object(OfferWeekController), 'offerweekAction'), array(object(Request), '0'))
in /server/xyz/Symfony/app/bootstrap.php.cache line 2770
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /server/xyz/Symfony/app/bootstrap.php.cache line 2744
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /server/xyz/Symfony/app/bootstrap.php.cache line 2874
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /server/xyz/Symfony/app/bootstrap.php.cache line 2175
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /server/xyz/Symfony/web/app_dev.php line 30
Thanks in advance for your help.
sectorcolumn? It was used to persist a sector number but now you make that value an array instead of a number in your PHP code.doc:schema:updatecommand? By the way, I would suggest you to use symfony.com/fr/doc/current/bundles/DoctrineMigrationsBundle/… since it helps about migrating/reverting easily.php app/console doctrine:schema:validateto be sure that the mapping is OK, and then dump $sector in your setSector please?