>백엔드 개발 >PHP 튜토리얼 >symfony 框架报错Unknown relation aliass

symfony 框架报错Unknown relation aliass

WBOY
WBOY원래의
2016-06-06 20:47:091111검색

symfony 框架报错Unknown relation aliass

就是这句代码报的错:

<code>$q = Doctrine_Query::create()->from('FzAnswerquestionResult r')->leftJoin('r.FzUsers u ON r.fb_id = u.user_id')
        ->groupBy('r.fb_id')->where('r.is_delete = 0 and u.province = "'.$province.'" and r.end_time >= '.$starttime.' and r.end_time </code>
<code>500 | Internal Server Error | Doctrine_Table_Exception
Unknown relation alias FzUsers
stack trace

    at ()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 237 ...
                        return $this->getRelation($alias, false);
                    } else {
                        throw new Doctrine_Table_Exception('Unknown relation alias ' . $alias);
                    }
                }
    at Doctrine_Relation_Parser->getRelation('FzUsers', )
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 235 ...
    at Doctrine_Relation_Parser->getRelation('FzUsers', 1)
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Table.php line 1001 ...
    at Doctrine_Table->getRelation('FzUsers')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1762 ...
    at Doctrine_Query->load('r.FzUsers u ON r.fb_id = u.user_id')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\From.php line 88 ...
    at Doctrine_Query_From->parse('LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 2084 ...
    at Doctrine_Query_Abstract->_processDqlQueryPart('from', array('FzAnswerquestionResult r', 'LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id'))
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1183 ...
    at Doctrine_Query->buildSqlQuery()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1149 ...
    at Doctrine_Query->getSqlQuery(array(), )
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2042 ...
    at Doctrine_Query->getCountSqlQuery()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2132 ...
    at Doctrine_Query->count()
    in SF_ROOT_DIR\lib\model\doctrine\FzAnswerquestionResult.class.php line 400 ...
    at FzAnswerquestionResult->getFbThisIssueUserNumByProvince('北京', 1388332800, 1397475117)
    in SF_ROOT_DIR\apps\frontend\modules\exam\actions\actions.class.php line 1313 ...
    at examActions->executeFbExamProvinceRank(object('sfWebRequest'))
    in SF_ROOT_DIR\lib\symfony\lib\action\sfActions.class.php line 60 ...
                }
                // run action
                return $this->$actionToRun($request);
              }
            }
    at sfActions->execute(object('sfWebRequest'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 92 ...
    at sfExecutionFilter->executeAction(object('examActions'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 78 ...
    at sfExecutionFilter->handleAction(object('sfFilterChain'), object('examActions'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 53 ...
    at sfExecutionFilter->execute(object('sfFilterChain'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
    at sfFilterChain->execute()
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfRenderingFilter.class.php line 33 ...
    at sfRenderingFilter->execute(object('sfFilterChain'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
    at sfFilterChain->execute()
    in SF_ROOT_DIR\lib\symfony\lib\controller\sfController.class.php line 238 ...
    at sfController->forward('exam', 'FbExamProvinceRank')
    in SF_ROOT_DIR\lib\symfony\lib\controller\sfFrontWebController.class.php line 48 ...
    at sfFrontWebController->dispatch()
    in SF_ROOT_DIR\lib\symfony\lib\util\sfContext.class.php line 170 ...
    at sfContext->dispatch()
    in SF_ROOT_DIR\web\index.php line 7 ...

symfony settings ...
request ...
response ...
user ...
global vars ...

symfony v.1.4.17 - php 5.2.6
for help resolving this issue, please visit http://www.symfony-project.org/. 
</code>

回复内容:

symfony 框架报错Unknown relation aliass

就是这句代码报的错:

<code>$q = Doctrine_Query::create()->from('FzAnswerquestionResult r')->leftJoin('r.FzUsers u ON r.fb_id = u.user_id')
        ->groupBy('r.fb_id')->where('r.is_delete = 0 and u.province = "'.$province.'" and r.end_time >= '.$starttime.' and r.end_time </code>
<code>500 | Internal Server Error | Doctrine_Table_Exception
Unknown relation alias FzUsers
stack trace

    at ()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 237 ...
                        return $this->getRelation($alias, false);
                    } else {
                        throw new Doctrine_Table_Exception('Unknown relation alias ' . $alias);
                    }
                }
    at Doctrine_Relation_Parser->getRelation('FzUsers', )
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 235 ...
    at Doctrine_Relation_Parser->getRelation('FzUsers', 1)
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Table.php line 1001 ...
    at Doctrine_Table->getRelation('FzUsers')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1762 ...
    at Doctrine_Query->load('r.FzUsers u ON r.fb_id = u.user_id')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\From.php line 88 ...
    at Doctrine_Query_From->parse('LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id')
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 2084 ...
    at Doctrine_Query_Abstract->_processDqlQueryPart('from', array('FzAnswerquestionResult r', 'LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id'))
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1183 ...
    at Doctrine_Query->buildSqlQuery()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1149 ...
    at Doctrine_Query->getSqlQuery(array(), )
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2042 ...
    at Doctrine_Query->getCountSqlQuery()
    in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2132 ...
    at Doctrine_Query->count()
    in SF_ROOT_DIR\lib\model\doctrine\FzAnswerquestionResult.class.php line 400 ...
    at FzAnswerquestionResult->getFbThisIssueUserNumByProvince('北京', 1388332800, 1397475117)
    in SF_ROOT_DIR\apps\frontend\modules\exam\actions\actions.class.php line 1313 ...
    at examActions->executeFbExamProvinceRank(object('sfWebRequest'))
    in SF_ROOT_DIR\lib\symfony\lib\action\sfActions.class.php line 60 ...
                }
                // run action
                return $this->$actionToRun($request);
              }
            }
    at sfActions->execute(object('sfWebRequest'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 92 ...
    at sfExecutionFilter->executeAction(object('examActions'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 78 ...
    at sfExecutionFilter->handleAction(object('sfFilterChain'), object('examActions'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 53 ...
    at sfExecutionFilter->execute(object('sfFilterChain'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
    at sfFilterChain->execute()
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfRenderingFilter.class.php line 33 ...
    at sfRenderingFilter->execute(object('sfFilterChain'))
    in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
    at sfFilterChain->execute()
    in SF_ROOT_DIR\lib\symfony\lib\controller\sfController.class.php line 238 ...
    at sfController->forward('exam', 'FbExamProvinceRank')
    in SF_ROOT_DIR\lib\symfony\lib\controller\sfFrontWebController.class.php line 48 ...
    at sfFrontWebController->dispatch()
    in SF_ROOT_DIR\lib\symfony\lib\util\sfContext.class.php line 170 ...
    at sfContext->dispatch()
    in SF_ROOT_DIR\web\index.php line 7 ...

symfony settings ...
request ...
response ...
user ...
global vars ...

symfony v.1.4.17 - php 5.2.6
for help resolving this issue, please visit http://www.symfony-project.org/. 
</code>

http://docs.doctrine-project.org/en/2.0.x/reference/query-builder.html

应该是这样的吧:

<code class="lang-php">Doctrine_Query::create()
->from('FzAnswerquestionResult r')
->leftJoin('r.FzUsers', 'u')
</code>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.