Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Security Level: All
-
Labels:None
-
Environment:Hide
« Hide
GNU/Gentoo Linux
Linux 2.6.38-reiser4-r6 #7 SMP PREEMPT Thu Dec 1 23:30:19 CET 2011 x86_64 Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz GenuineIntel GNU/Linux
php -v
PHP 5.3.8-pl0-gentoo (cli) (built: Dec 1 2011 19:06:08)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
./symfony2 -v
Symfony version 2.0.4 - app/dev/debugShow« Hide GNU/Gentoo Linux Linux 2.6.38-reiser4-r6 #7 SMP PREEMPT Thu Dec 1 23:30:19 CET 2011 x86_64 Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz GenuineIntel GNU/Linux php -v PHP 5.3.8-pl0-gentoo (cli) (built: Dec 1 2011 19:06:08) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies ./symfony2 -v Symfony version 2.0.4 - app/dev/debug
Description
A Foo Entity has the following association:
/**
- @ORM\OneToOne(targetEntity="Domain", inversedBy="WebSite")
- @ORM\JoinColumn(name="domain", referencedColumnName="domain", nullable=false)
*/
private $domain;
which fails to query by the following method ( note the array of values in the findBy() ):
$this->doctrine->getEntityManager( 'default' )>getRepository( '\myVendor\myBundle\Entity\myEntity' )>findBy( array( 'myProperty' => array( 'myValue' ) ) );
Curioously that does work ( note it has no values array ):
$this->doctrine->getEntityManager( 'default' )>getRepository( '\myVendor\myBundle\Entity\myEntity' )>findBy( array( 'myProperty' => 'myValue' ) );
The error i get on the first query is:
Notice: Undefined index: myProperty in /home/developer/public_html/myProject/vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1324
Finally as workaround i went with:
$em->createQuery('SELECT uws FROM MyProject\Model\WebSite ws JOIN ws.domain WHERE ws.domain =
');
//Here passed the array of parameters
and had no problems
This works with Doctrine 2.2.*, see test https://github.com/doctrine/doctrine2/commit/2e79637be83449f9558e3f1eb326b582299a50eb
You can pass an array of values and it will create a query:
SELECT * FROM Entity WHERE association_id IN
and use Doctrine\DBAL\Connection::PARAM_INT_ARRAY to build the query.