On Wed, Feb 05, 2014 at 11:08:45AM +0100, Marco Pivetta wrote:
> Hi Thomas,
> 
> I don't see any obvious mistakes in your query - did you validate your
> mappings first?

They are OK, when there are items with that itemfunctions, it will find frogs.

(I did run it, no complains.)

> What is the exact version of doctrine/orm in your `composer.lock`?

"name": "doctrine/orm",
"version": "v2.4.1",

(Sorry for forgetting this one)

But, I'll give you a more exact (but maybe embarrasing) query:

        $dql = <<<EODQL
SELECT m
FROM NTE\InventoryBundle\Entity\Model m
WHERE
m.id in (
    SELECT distinct(i.model)
    FROM NTE\InventoryBundle\Entity\Item i
    WHERE i.function = :itemfunction
    )
EODQL;

As you can see, "Frog" is actually named "Model", which may have been a bad 
mistake as it may work as if it were a reserved word. (And it's confusing
anyway..)

But it shouldn't break just when there are no items with that function.


Thomas.

> 
> 
> Marco Pivetta
> 
> http://twitter.com/Ocramius
> 
> http://ocramius.github.com/
> 
> 
> On 5 February 2014 11:05, Thomas Lundquist <[email protected]>wrote:
> 
> >
> > Hello group.
> >
> >
> > I have this little query in a repo:
> >
> >  -- snip --
> >
> >         $dql = <<<EODQL
> > SELECT f
> > FROM Foo\BarBundle\Entity\Frog f
> > WHERE
> > f.id in (
> >     SELECT distinct(i.frog)
> >     FROM NTE\InventoryBundle\Entity\Item i
> >     WHERE i.function = :itemfunction
> >     )
> > EODQL;
> >
> > $q = $this->_em->createQuery($dql);
> > $q->setParameter('itemfunction', $itemfunction);
> >
> > return $q->getResult();
> >
> >  -- snip --
> >
> > When there are no items with the itemfunction from the sub select, I end up
> > with these two:
> >
> > PHP Warning:  Illegal offset type in
> >  doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php on line 601,
> >
> > And
> >
> > PHP Fatal error:  Call to a member function getTableName() on a non-object
> > in
> > doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php on line 602
> >
> >
> > Doctrine version (from composer.lock):
> >
> > "name": "doctrine/dbal",
> > "version": "v2.4.2",
> >
> > Symfony 2.4.1 (If that's of any interest)
> >
> > So, is this just the stupid and wrong way to query or a bug?
> >
> > Doing (well, close) this in SQL gives 0 rows and no error.
> >
> >
> > Thomas.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "doctrine-user" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/doctrine-user.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to