Home > Backend Development > PHP Tutorial > symfony 框架报错Unknown relation aliass

symfony 框架报错Unknown relation aliass

WBOY
Release: 2016-06-06 20:47:09
Original
1136 people have browsed it

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>
Copy after login
Copy after login
<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>
Copy after login
Copy after login

回复内容:

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>
Copy after login
Copy after login
<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>
Copy after login
Copy after login

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template