Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDC-1705: BasicEntityPersister throws error undefined index #2354

Closed
doctrinebot opened this issue Mar 15, 2012 · 3 comments
Closed

DDC-1705: BasicEntityPersister throws error undefined index #2354

doctrinebot opened this issue Mar 15, 2012 · 3 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user vigor_bg:

In the BasicEntityPersister in the _getInsertSQL function when you are foreaching the columns you make a check

if (isset($this->_columnTypes[$column]) &&
                        isset($this->*class->fieldMappings[$this->*class->fieldNames[$column]]['requireSQLConversion'])) {
                        $type = Type::getType($this->_columnTypes[$column]);
                        $placeholder = $type->convertToDatabaseValueSQL('?', $this->_platform);
                    }

the problem is in

  isset($this->*class->fieldMappings[$this->*class->fieldNames[$column]]['requireSQLConversion'])

because you are not checking if it is set

$this->_class->fieldNames[$column]

i got that problem when was saving ManyToOne association

@doctrinebot
Copy link
Author

Comment created by schwede:

I got the same error and used error handling to throw an exception of this notice:

PHP Fatal error: Uncaught exception 'ErrorException' with message 'Undefined index: currentPrice_id' in /usr/share/php/Doctrine/ORM/Persisters/BasicEntityPersister.php:1146
Stack trace:
#0 /usr/share/php/Doctrine/ORM/Persisters/BasicEntityPersister.php(1146): exception_error_handler(8, 'Undefined index...', '/usr/share/php/...', 1146, Array)
#1 /usr/share/php/Doctrine/ORM/Persisters/BasicEntityPersister.php(225): Doctrine\ORM\Persisters\BasicEntityPersister->_getInsertSQL()
#2 /usr/share/php/Doctrine/ORM/UnitOfWork.php(896): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts()
#3 /usr/share/php/Doctrine/ORM/UnitOfWork.php(304): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrine\ORM\Mapping\ClassMetadata))
#4 /usr/share/php/Doctrine/ORM/EntityManager.php(355): Doctrine\ORM\UnitOfWork->commit(NULL)
#5 /var/www/app/module/Application/src/Application/Entity/Model.php(29): Doctrine\ORM\EntityManager->flush()
#6 /var/www/app/module/Application/src/Application/Entity/ in /usr/share/php/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 1146

My mappings look like this:

/****
 * 
 * @ORM\OneToMany(targetEntity="Price", mappedBy="product", cascade={"all"})
 * @ORM\OrderBy({"date" = "DESC"})
 */
protected $prices;

/****
 * @ORM\ManyToOne(targetEntity="Price", inversedBy="currentProducts",cascade={"all"})
 */
protected $currentPrice;

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants