DDC-1713: Doctrine2 findBy( 'myFKAssociacionProperty' => array( 'foo' ) ); not working #2363

doctrinebot opened this Issue Mar 17, 2012 · 2 comments

2 participants


Jira issue originally created by user sibok:

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


Comment created by @beberlei:

This works with Doctrine 2.2.*, see test 2e79637

You can pass an array of values and it will create a query:

SELECT * FROM Entity WHERE associationid IN (?) and use Doctrine\DBAL\Connection::PARAM_INTARRAY to build the query.


Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this 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