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-1713: Doctrine2 findBy( 'myFKAssociacionProperty' => array( 'foo' ) ); not working #2363

Closed
doctrinebot opened this issue Mar 17, 2012 · 2 comments
Assignees
Labels

Comments

@doctrinebot
Copy link

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

@doctrinebot
Copy link
Author

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 association_id IN (?) and use Doctrine\DBAL\Connection::PARAM_INT_ARRAY to build the query.

@doctrinebot
Copy link
Author

Issue was closed with resolution "Invalid"

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