Doctrine 2对简单查询给出500错误

时间:2015-07-01 10:34:50

标签: symfony doctrine-orm

我有这个学说查询:

$attributeQuery = $em->createQuery("SELECT PARTIAL p.{id} FROM m:Product p JOIN m:BtgNode n WITH n.attribute = p.amazonCatUs1 WHERE n.id = :node")->setMaxResults(5);
$attributeQuery->setParameter('node', $amazonCategoryId);
$products = $attributeQuery->getResult();

导致500错误。当我注释掉getResult行时,页面完成加载,当我运行$attributeQuery->getSql()并通过phpmyadmin执行结果时,结果在不到0.001秒的时间内正确返回。

我找不到任何可以解释这种行为的事情。

完整的脚本:

$em = $app['orm.em'];
        echo ini_get('memory_limit').'<br>';

        ini_set('xdebug.var_display_max_depth', -1);
        ini_set('xdebug.var_display_max_data', -1);

        $productQuery = $em->createQuery("SELECT p FROM m:Product p WHERE p.amazonUsBrowse1 = :node OR p.amazonUsBrowse2 = :node");
        $productQuery->setParameter('node', $amazonCategoryId);
        $productQuery->useQueryCache(false);

        //if results, then not clothing and simple, else complicated
        $products = $productQuery->getResult();
        print memory_get_usage(true);
        if (count($products) == 0) {
            $em->clear();
            echo 'complex';

            $attributeQuery = $em->createQuery("SELECT PARTIAL p.{id} FROM m:Product p JOIN m:BtgNode n WITH n.attribute = p.amazonCatUs1 WHERE n.id = :node")->setMaxResults(5);
            $attributeQuery->setParameter('node', $amazonCategoryId);
            //$attributeQuery->useQueryCache(false);
            var_dump($attributeQuery->getSql());

            $products = $attributeQuery->getResult();
            var_dump($attributeQuery->getSql());
        }
        var_dump($products);
        die();

0 个答案:

没有答案